← Commit list

480c7e5df

Denys Vlasenko
Denys Vlasenko
2018-11-29
SUCCESS Duration: 273s

Subject

libbb: @ in "\x3@" is not a valid hex digit

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

libbb/process_escape_sequence.c+10 -2
@@ -41,8 +41,16 @@ char FAST_FUNC bb_process_escape_sequence(const char **ptr)
unsigned d = (unsigned char)(*q) - '0';
#else
unsigned d = (unsigned char)_tolower(*q) - '0';
- if (d >= 10)
- d += ('0' - 'a' + 10);
+ if (d >= 10) {
+ //d += ('0' - 'a' + 10);
+ /* The above would maps 'A'-'F' and 'a'-'f' to 10-15,
+ * however, some chars like '@' would map to 9 < base.
+ * Do not allow that, map invalid chars to N > base:
+ */
+ d += ('0' - 'a');
+ if ((int)d >= 0)
+ d += 10;
+ }
#endif
if (d >= base) {
if (WANT_HEX_ESCAPES && base == 16) {