Commit f97ca2c8 authored by Arvind Sankar's avatar Arvind Sankar Committed by Ard Biesheuvel

efi/printf: Abort on invalid format

If we get an invalid conversion specifier, bail out instead of trying to
fix it up. The format string likely has a typo or assumed we support
something that we don't, in either case the remaining arguments won't
match up with the remaining format string.
Signed-off-by: default avatarArvind Sankar <nivedita@alum.mit.edu>
Link: https://lore.kernel.org/r/20200518190716.751506-16-nivedita@alum.mit.eduSigned-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
parent 6c4bcd8a
...@@ -359,12 +359,13 @@ int vsprintf(char *buf, const char *fmt, va_list ap) ...@@ -359,12 +359,13 @@ int vsprintf(char *buf, const char *fmt, va_list ap)
break; break;
default: default:
*str++ = '%'; /*
if (*fmt) * Bail out if the conversion specifier is invalid.
*str++ = *fmt; * There's probably a typo in the format string and the
else * remaining specifiers are unlikely to match up with
--fmt; * the arguments.
continue; */
goto fail;
} }
if (*fmt == 'p') { if (*fmt == 'p') {
num = (unsigned long)va_arg(args, void *); num = (unsigned long)va_arg(args, void *);
...@@ -434,6 +435,7 @@ int vsprintf(char *buf, const char *fmt, va_list ap) ...@@ -434,6 +435,7 @@ int vsprintf(char *buf, const char *fmt, va_list ap)
while (field_width-- > 0) while (field_width-- > 0)
*str++ = ' '; *str++ = ' ';
} }
fail:
*str = '\0'; *str = '\0';
va_end(args); va_end(args);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment