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>
This commit is contained in:
parent
480c7e5dfb
commit
9a2b6dcc2d
@ -37,17 +37,15 @@ char FAST_FUNC bb_process_escape_sequence(const char **ptr)
|
|||||||
* We treat \2 as a valid octal escape sequence. */
|
* We treat \2 as a valid octal escape sequence. */
|
||||||
do {
|
do {
|
||||||
unsigned r;
|
unsigned r;
|
||||||
#if !WANT_HEX_ESCAPES
|
|
||||||
unsigned d = (unsigned char)(*q) - '0';
|
unsigned d = (unsigned char)(*q) - '0';
|
||||||
#else
|
#if WANT_HEX_ESCAPES
|
||||||
unsigned d = (unsigned char)_tolower(*q) - '0';
|
|
||||||
if (d >= 10) {
|
if (d >= 10) {
|
||||||
//d += ('0' - 'a' + 10);
|
d = (unsigned char)_tolower(*q) - 'a';
|
||||||
/* The above would maps 'A'-'F' and 'a'-'f' to 10-15,
|
//d += 10;
|
||||||
|
/* The above would map 'A'-'F' and 'a'-'f' to 10-15,
|
||||||
* however, some chars like '@' would map to 9 < base.
|
* however, some chars like '@' would map to 9 < base.
|
||||||
* Do not allow that, map invalid chars to N > base:
|
* Do not allow that, map invalid chars to N > base:
|
||||||
*/
|
*/
|
||||||
d += ('0' - 'a');
|
|
||||||
if ((int)d >= 0)
|
if ((int)d >= 0)
|
||||||
d += 10;
|
d += 10;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user