aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-11-29 13:15:57 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2018-11-29 13:16:15 +0100
commit9a2b6dcc2d3298499b88aea3b04c967f2f9ae965 (patch)
tree5b29b816b942db32d516a6afba8d70899eb51414 /libbb
parent480c7e5dfbddafa763f241aecfe3831d2b3dfca5 (diff)
downloadbusybox-w32-9a2b6dcc2d3298499b88aea3b04c967f2f9ae965.tar.gz
busybox-w32-9a2b6dcc2d3298499b88aea3b04c967f2f9ae965.tar.bz2
busybox-w32-9a2b6dcc2d3298499b88aea3b04c967f2f9ae965.zip
libbb: do not misinterpret 0x10-0x19 chars in "\xNNN" too
function old new delta bb_process_escape_sequence 141 151 +10 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb')
-rw-r--r--libbb/process_escape_sequence.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/libbb/process_escape_sequence.c b/libbb/process_escape_sequence.c
index 11adbfcea..13022b83e 100644
--- a/libbb/process_escape_sequence.c
+++ b/libbb/process_escape_sequence.c
@@ -37,17 +37,15 @@ char FAST_FUNC bb_process_escape_sequence(const char **ptr)
37 * We treat \2 as a valid octal escape sequence. */ 37 * We treat \2 as a valid octal escape sequence. */
38 do { 38 do {
39 unsigned r; 39 unsigned r;
40#if !WANT_HEX_ESCAPES
41 unsigned d = (unsigned char)(*q) - '0'; 40 unsigned d = (unsigned char)(*q) - '0';
42#else 41#if WANT_HEX_ESCAPES
43 unsigned d = (unsigned char)_tolower(*q) - '0';
44 if (d >= 10) { 42 if (d >= 10) {
45 //d += ('0' - 'a' + 10); 43 d = (unsigned char)_tolower(*q) - 'a';
46 /* The above would maps 'A'-'F' and 'a'-'f' to 10-15, 44 //d += 10;
45 /* The above would map 'A'-'F' and 'a'-'f' to 10-15,
47 * however, some chars like '@' would map to 9 < base. 46 * however, some chars like '@' would map to 9 < base.
48 * Do not allow that, map invalid chars to N > base: 47 * Do not allow that, map invalid chars to N > base:
49 */ 48 */
50 d += ('0' - 'a');
51 if ((int)d >= 0) 49 if ((int)d >= 0)
52 d += 10; 50 d += 10;
53 } 51 }