mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-08-06 18:22:25 +02:00
set of portability changes from lint/asan/ubsan
This commit is contained in:
+3
-3
@@ -113,7 +113,7 @@ fprintf(stderr, "gmatch: pattern = %s; pe = %s\n", pattern, pe);
|
||||
we are matching a pathname. */
|
||||
if ((flags & FNM_DOTDOT) &&
|
||||
((n == string && SDOT_OR_DOTDOT(n)) ||
|
||||
((flags & FNM_PATHNAME) && n[-1] == L('/') && PDOT_OR_DOTDOT(n))))
|
||||
((flags & FNM_PATHNAME) && n > string && n[-1] == L('/') && PDOT_OR_DOTDOT(n))))
|
||||
return FNM_NOMATCH;
|
||||
|
||||
break;
|
||||
@@ -159,7 +159,7 @@ fprintf(stderr, "gmatch: pattern = %s; pe = %s\n", pattern, pe);
|
||||
we are matching a pathname. */
|
||||
if ((flags & FNM_DOTDOT) &&
|
||||
((n == string && SDOT_OR_DOTDOT(n)) ||
|
||||
((flags & FNM_PATHNAME) && n[-1] == L('/') && PDOT_OR_DOTDOT(n))))
|
||||
((flags & FNM_PATHNAME) && n > string && n[-1] == L('/') && PDOT_OR_DOTDOT(n))))
|
||||
return FNM_NOMATCH;
|
||||
|
||||
if (p == pe)
|
||||
@@ -346,7 +346,7 @@ fprintf(stderr, "gmatch: pattern = %s; pe = %s\n", pattern, pe);
|
||||
we are matching a pathname. */
|
||||
if ((flags & FNM_DOTDOT) &&
|
||||
((n == string && SDOT_OR_DOTDOT(n)) ||
|
||||
((flags & FNM_PATHNAME) && n[-1] == L('/') && PDOT_OR_DOTDOT(n))))
|
||||
((flags & FNM_PATHNAME) && n > string && n[-1] == L('/') && PDOT_OR_DOTDOT(n))))
|
||||
return FNM_NOMATCH;
|
||||
|
||||
p = BRACKMATCH (p, sc, flags);
|
||||
|
||||
+3
-3
@@ -2677,7 +2677,7 @@ rl_invoking_keyseqs_in_map (rl_command_func_t *function, Keymap map)
|
||||
{
|
||||
register int key;
|
||||
char **result;
|
||||
int result_index, result_size;
|
||||
size_t result_index, result_size;
|
||||
|
||||
result = (char **)NULL;
|
||||
result_index = result_size = 0;
|
||||
@@ -2874,9 +2874,9 @@ rl_dump_functions (int count, int key)
|
||||
static void
|
||||
_rl_macro_dumper_internal (int print_readably, Keymap map, char *prefix)
|
||||
{
|
||||
register int key;
|
||||
int key;
|
||||
char *keyname, *out;
|
||||
int prefix_len;
|
||||
size_t prefix_len;
|
||||
|
||||
for (key = 0; key < KEYMAP_SIZE; key++)
|
||||
{
|
||||
|
||||
@@ -2206,7 +2206,7 @@ rl_completion_matches (const char *text, rl_compentry_func_t *entry_function)
|
||||
register int i;
|
||||
|
||||
/* Number of slots in match_list. */
|
||||
int match_list_size;
|
||||
size_t match_list_size;
|
||||
|
||||
/* The list of matches. */
|
||||
char **match_list;
|
||||
|
||||
@@ -664,8 +664,8 @@ rl_expand_prompt (char *prompt)
|
||||
static void
|
||||
realloc_line (int minsize)
|
||||
{
|
||||
int minimum_size;
|
||||
int newsize, delta;
|
||||
size_t minimum_size;
|
||||
size_t newsize, delta;
|
||||
|
||||
minimum_size = DEFAULT_LINE_BUFFER_SIZE;
|
||||
if (minsize < minimum_size)
|
||||
@@ -809,7 +809,7 @@ rl_redisplay (void)
|
||||
{
|
||||
int in, out, c, linenum, cursor_linenum;
|
||||
int inv_botlin, lb_botlin, lb_linenum, o_cpos;
|
||||
int newlines, lpos, temp, n0, num, prompt_lines_estimate;
|
||||
int newlines, lpos, temp, num, prompt_lines_estimate;
|
||||
char *prompt_this_line;
|
||||
char cur_face;
|
||||
int hl_begin, hl_end;
|
||||
|
||||
@@ -49,7 +49,7 @@ typedef int QSFUNC ();
|
||||
extern int _rl_qsort_string_compare (char **, char **);
|
||||
|
||||
FUNMAP **funmap;
|
||||
static int funmap_size;
|
||||
static size_t funmap_size;
|
||||
static int funmap_entry;
|
||||
|
||||
/* After initializing the function map, this is the index of the first
|
||||
@@ -251,7 +251,7 @@ const char **
|
||||
rl_funmap_names (void)
|
||||
{
|
||||
const char **result;
|
||||
int result_size, result_index;
|
||||
size_t result_size, result_index;
|
||||
|
||||
/* Make sure that the function map has been initialized. */
|
||||
rl_initialize_funmap ();
|
||||
|
||||
@@ -528,6 +528,8 @@ history_truncate_file (const char *fname, int lines)
|
||||
file = filename ? open (filename, O_RDONLY|O_BINARY, 0666) : -1;
|
||||
rv = exists = 0;
|
||||
|
||||
orig_lines = lines;
|
||||
|
||||
/* Don't try to truncate non-regular files. */
|
||||
if (file == -1 || fstat (file, &finfo) == -1)
|
||||
{
|
||||
@@ -585,7 +587,6 @@ history_truncate_file (const char *fname, int lines)
|
||||
goto truncate_exit;
|
||||
}
|
||||
|
||||
orig_lines = lines;
|
||||
/* Count backwards from the end of buffer until we have passed
|
||||
LINES lines. bp1 is set funny initially. But since bp[1] can't
|
||||
be a comment character (since it's off the end) and *bp can't be
|
||||
|
||||
@@ -150,7 +150,7 @@ static void
|
||||
rl_display_search (char *search_string, int flags, int where)
|
||||
{
|
||||
char *message;
|
||||
int msglen, searchlen;
|
||||
size_t msglen, searchlen;
|
||||
|
||||
searchlen = (search_string && *search_string) ? strlen (search_string) : 0;
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ static int vi_replace_count;
|
||||
us implicitly into insert mode. Some people want this text to be
|
||||
attached to the command so that it is `redoable' with `.'. */
|
||||
static char *vi_insert_buffer;
|
||||
static int vi_insert_buffer_size;
|
||||
static size_t vi_insert_buffer_size;
|
||||
|
||||
static int _rl_vi_last_repeat = 1;
|
||||
static int _rl_vi_last_arg_sign = 1;
|
||||
|
||||
+5
-3
@@ -48,7 +48,7 @@ extern int errno;
|
||||
|
||||
extern char *get_working_directory (char *);
|
||||
|
||||
static inline int
|
||||
static inline ssize_t
|
||||
_path_readlink (char *path, char *buf, size_t bufsiz)
|
||||
{
|
||||
#ifdef HAVE_READLINK
|
||||
@@ -74,6 +74,7 @@ sh_physpath (char *path, int flags)
|
||||
char tbuf[PATH_MAX+1], linkbuf[PATH_MAX+1];
|
||||
char *result, *p, *q, *qsave, *qbase, *workpath;
|
||||
int double_slash_path, nlink;
|
||||
ssize_t r;
|
||||
size_t linklen;
|
||||
|
||||
linklen = strlen (path);
|
||||
@@ -160,13 +161,14 @@ sh_physpath (char *path, int flags)
|
||||
|
||||
*q = '\0';
|
||||
|
||||
linklen = _path_readlink (result, linkbuf, PATH_MAX);
|
||||
if (linklen < 0) /* if errno == EINVAL, it's not a symlink */
|
||||
r = _path_readlink (result, linkbuf, PATH_MAX);
|
||||
if (r < 0) /* if errno == EINVAL, it's not a symlink */
|
||||
{
|
||||
if (errno != EINVAL)
|
||||
goto error;
|
||||
continue;
|
||||
}
|
||||
linklen = r;
|
||||
|
||||
/* It's a symlink, and the value is in LINKBUF. */
|
||||
nlink++;
|
||||
|
||||
+4
-3
@@ -255,18 +255,19 @@ sh_un_double_quote (char *string)
|
||||
other shell blank characters. */
|
||||
|
||||
char *
|
||||
sh_backslash_quote (char *string, char *table, int flags)
|
||||
sh_backslash_quote (char *string, const char *table, int flags)
|
||||
{
|
||||
int c, mb_cur_max;
|
||||
size_t slen;
|
||||
char *result, *r, *s, *backslash_table, *send;
|
||||
char *result, *r, *s, *send;
|
||||
const char *backslash_table;
|
||||
DECLARE_MBSTATE;
|
||||
|
||||
slen = strlen (string);
|
||||
send = string + slen;
|
||||
result = (char *)xmalloc (2 * slen + 1);
|
||||
|
||||
backslash_table = table ? table : (char *)bstab;
|
||||
backslash_table = table ? table : bstab;
|
||||
mb_cur_max = MB_CUR_MAX;
|
||||
|
||||
for (r = result, s = string; s && (c = *s); s++)
|
||||
|
||||
+2
-2
@@ -130,8 +130,8 @@ strvec_search (char **array, const char *name)
|
||||
char **
|
||||
strvec_copy (char * const *array)
|
||||
{
|
||||
register int i;
|
||||
int len;
|
||||
int i;
|
||||
size_t len;
|
||||
char **ret;
|
||||
|
||||
len = strvec_len (array);
|
||||
|
||||
+4
-3
@@ -48,7 +48,7 @@
|
||||
quote CTLESC and CTLNUL with CTLESC. If (flags&4) is non-zero, we want
|
||||
to remove the backslash before any unrecognized escape sequence. */
|
||||
char *
|
||||
ansicstr (const char *string, int len, int flags, int *sawc, int *rlen)
|
||||
ansicstr (const char *string, size_t len, int flags, int *sawc, size_t *rlen)
|
||||
{
|
||||
int c, temp;
|
||||
char *ret, *r;
|
||||
@@ -370,10 +370,11 @@ ansic_shouldquote (const char *string)
|
||||
/* $'...' ANSI-C expand the portion of STRING between START and END and
|
||||
return the result. The result cannot be longer than the input string. */
|
||||
char *
|
||||
ansiexpand (const char *string, int start, int end, int *lenp)
|
||||
ansiexpand (const char *string, int start, int end, size_t *lenp)
|
||||
{
|
||||
char *temp, *t;
|
||||
int len, tlen;
|
||||
int len;
|
||||
size_t tlen;
|
||||
|
||||
temp = (char *)xmalloc (end - start + 1);
|
||||
for (tlen = 0, len = start; len < end; )
|
||||
|
||||
+5
-4
@@ -160,8 +160,9 @@ tilde_find_prefix (const char *string, int *len)
|
||||
static int
|
||||
tilde_find_suffix (const char *string)
|
||||
{
|
||||
register int i, j, string_len;
|
||||
register char **suffixes;
|
||||
int i, j;
|
||||
size_t string_len;
|
||||
char **suffixes;
|
||||
|
||||
suffixes = tilde_additional_suffixes;
|
||||
string_len = strlen (string);
|
||||
@@ -189,7 +190,7 @@ char *
|
||||
tilde_expand (const char *string)
|
||||
{
|
||||
char *result;
|
||||
int result_size, result_index;
|
||||
size_t result_size, result_index;
|
||||
|
||||
result_index = result_size = 0;
|
||||
if (result = strchr (string, '~'))
|
||||
@@ -200,7 +201,7 @@ tilde_expand (const char *string)
|
||||
/* Scan through STRING expanding tildes as we come to them. */
|
||||
while (1)
|
||||
{
|
||||
register int start, end;
|
||||
int start, end;
|
||||
char *tilde_word, *expansion;
|
||||
int len;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user