← Commit list

69d81a1c1

Denys Vlasenko
Denys Vlasenko
2012-03-07
FAILED Duration: 220s

Subject

printf: fix this case: printf "%b" '\0057usr\0057bin\n'

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 →

coreutils/printf.c+17 -2
@@ -131,13 +131,28 @@ static double my_xstrtod(const char *arg)
return result;
}
+/* Handles %b */
static void print_esc_string(const char *str)
{
char c;
while ((c = *str) != '\0') {
str++;
- if (c == '\\')
- c = bb_process_escape_sequence(&str);
+ if (c == '\\') {
+ /* %b also accepts 4-digit octals of the form \0### */
+ if (*str == '0') {
+ if ((unsigned char)(str[1] - '0') < 8) {
+ /* 2nd char is 0..7: skip leading '0' */
+ str++;
+ }
+ }
+ {
+ /* optimization: don't force arg to be on-stack,
+ * use another variable for that. */
+ const char *z = str;
+ c = bb_process_escape_sequence(&z);
+ str = z;
+ }
+ }
putchar(c);
}
}