bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Array subscript with char


From: Roland Illig
Subject: Array subscript with char
Date: Tue, 17 Mar 2020 18:17:07 +0100
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Thunderbird/75.0

When I compiled bash-5.0 patchlevel 16 with gcc -Werror=char-subscripts,
the attached files didn't compile cleanly.

Please have a look at whether the patches are correct, and if so, apply
them.

Thanks,
Roland
$NetBSD: patch-bashline.c,v 1.1 2020/03/17 17:09:48 rillig Exp $

Fix array subscript with char index.

--- bashline.c.orig     2020-03-17 16:57:19.058552795 +0000
+++ bashline.c
@@ -4050,7 +4050,7 @@ set_filename_bstab (string)
 
   memset (filename_bstab, 0, sizeof (filename_bstab));
   for (s = string; s && *s; s++)
-    filename_bstab[*s] = 1;
+    filename_bstab[(unsigned char) *s] = 1;
 }
 
 /* Quote a filename using double quotes, single quotes, or backslashes
$NetBSD: patch-lib_malloc_malloc.c,v 1.1 2020/03/17 17:09:48 rillig Exp $

Fix array subscript with char index.

--- lib/malloc/malloc.c.orig    2018-06-20 13:55:09.000000000 +0000
+++ lib/malloc/malloc.c
@@ -266,7 +266,7 @@ static const unsigned long binsizes[NBUC
 };
 
 /* binsizes[x] == (1 << ((x) + 3)) */
-#define binsize(x)     binsizes[(x)]
+#define binsize(x)     binsizes[(size_t) (x)]
 
 #if !defined (errno)
 extern int errno;
$NetBSD: patch-subst.c,v 1.1 2020/03/17 17:09:48 rillig Exp $

Fix array subscript with char index.

--- subst.c.orig        2020-03-17 16:57:17.469764555 +0000
+++ subst.c
@@ -11294,7 +11294,7 @@ shell_expand_word_list (tlist, eflags)
                        case 'l':
                        case 'u':
                        case 'c':
-                         omap[l->word->word[oind]] = 1;
+                         omap[(unsigned char) l->word->word[oind]] = 1;
                          if (opti == 0)
                            opts[opti++] = '-';
                          break;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]