diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2016-12-12 17:39:12 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2016-12-12 17:39:12 +0100 |
commit | 2fe66b1d2dc50f9d5ed98d5c537745f3066fb4d8 (patch) | |
tree | 1019d90dd8842539a2c23ef260c2a6749df28067 | |
parent | b6afcc78194aa0801544bc606b9562339c846eb4 (diff) | |
download | busybox-w32-2fe66b1d2dc50f9d5ed98d5c537745f3066fb4d8.tar.gz busybox-w32-2fe66b1d2dc50f9d5ed98d5c537745f3066fb4d8.tar.bz2 busybox-w32-2fe66b1d2dc50f9d5ed98d5c537745f3066fb4d8.zip |
ash: fix signed char expansion bug
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | shell/ash.c | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/shell/ash.c b/shell/ash.c index 91bcccb9d..8d8cc466b 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -3113,7 +3113,18 @@ static const uint8_t syntax_index_table[] ALIGN1 = { | |||
3113 | # endif | 3113 | # endif |
3114 | }; | 3114 | }; |
3115 | 3115 | ||
3116 | #if 1 | ||
3116 | # define SIT(c, syntax) ((S_I_T[syntax_index_table[c]] >> ((syntax)*4)) & 0xf) | 3117 | # define SIT(c, syntax) ((S_I_T[syntax_index_table[c]] >> ((syntax)*4)) & 0xf) |
3118 | #else /* debug version, caught one signed char bug */ | ||
3119 | # define SIT(c, syntax) \ | ||
3120 | ({ \ | ||
3121 | if ((c) < 0 || (c) > (PEOF + ENABLE_ASH_ALIAS)) \ | ||
3122 | bb_error_msg_and_die("line:%d c:%d", __LINE__, (c)); \ | ||
3123 | if ((syntax) < 0 || (syntax) > (2 + ENABLE_SH_MATH_SUPPORT)) \ | ||
3124 | bb_error_msg_and_die("line:%d c:%d", __LINE__, (c)); \ | ||
3125 | ((S_I_T[syntax_index_table[c]] >> ((syntax)*4)) & 0xf); \ | ||
3126 | }) | ||
3127 | #endif | ||
3117 | 3128 | ||
3118 | #endif /* !USE_SIT_FUNCTION */ | 3129 | #endif /* !USE_SIT_FUNCTION */ |
3119 | 3130 | ||
@@ -5869,14 +5880,15 @@ memtodest(const char *p, size_t len, int syntax, int quotes) | |||
5869 | do { | 5880 | do { |
5870 | unsigned char c = *p++; | 5881 | unsigned char c = *p++; |
5871 | if (c) { | 5882 | if (c) { |
5872 | int n = SIT(c, syntax); | 5883 | if (quotes & QUOTES_ESC) { |
5873 | if ((quotes & QUOTES_ESC) | 5884 | int n = SIT(c, syntax); |
5874 | && ((n == CCTL) | 5885 | if (n == CCTL |
5875 | || (((quotes & EXP_FULL) || syntax != BASESYNTAX) | 5886 | || (((quotes & EXP_FULL) || syntax != BASESYNTAX) |
5876 | && n == CBACK) | 5887 | && n == CBACK |
5877 | ) | 5888 | ) |
5878 | ) { | 5889 | ) { |
5879 | USTPUTC(CTLESC, q); | 5890 | USTPUTC(CTLESC, q); |
5891 | } | ||
5880 | } | 5892 | } |
5881 | } else if (!(quotes & QUOTES_KEEPNUL)) | 5893 | } else if (!(quotes & QUOTES_KEEPNUL)) |
5882 | continue; | 5894 | continue; |
@@ -10051,7 +10063,7 @@ pgetc(void) | |||
10051 | return g_parsefile->lastc[--g_parsefile->unget]; | 10063 | return g_parsefile->lastc[--g_parsefile->unget]; |
10052 | 10064 | ||
10053 | if (--g_parsefile->left_in_line >= 0) | 10065 | if (--g_parsefile->left_in_line >= 0) |
10054 | c = (signed char)*g_parsefile->next_to_pgetc++; | 10066 | c = (unsigned char)*g_parsefile->next_to_pgetc++; |
10055 | else | 10067 | else |
10056 | c = preadbuffer(); | 10068 | c = preadbuffer(); |
10057 | 10069 | ||