← Commit list

513a2457b

Ron Yorston
Ron Yorston
2017-07-18
SUCCESS Duration: 147s

Subject

printf: fix format string sanity check

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+2 -2
@@ -305,7 +305,7 @@ static char **print_formatted(char *f, char **argv, int *conv_err)
}
break;
}
- if (strchr("-+ #", *f)) {
+ if (*f && strchr("-+ #", *f)) {
++f;
++direc_length;
}
@@ -348,7 +348,7 @@ static char **print_formatted(char *f, char **argv, int *conv_err)
static const char format_chars[] ALIGN1 = "diouxXfeEgGcs";
char *p = strchr(format_chars, *f);
/* needed - try "printf %" without it */
- if (p == NULL) {
+ if (p == NULL || *f == '\0') {
bb_error_msg("%s: invalid format", direc_start);
/* causes main() to exit with error */
return saved_argv - 1;