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

efi/printf: Handle null string input

Print "(null)" for 's' if the input is a NULL pointer.
Signed-off-by: default avatarArvind Sankar <nivedita@alum.mit.edu>
Link: https://lore.kernel.org/r/20200518190716.751506-14-nivedita@alum.mit.eduSigned-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
parent dec61199
......@@ -14,6 +14,7 @@
#include <linux/compiler.h>
#include <linux/ctype.h>
#include <linux/limits.h>
#include <linux/string.h>
static int skip_atoi(const char **s)
......@@ -356,7 +357,11 @@ int vsprintf(char *buf, const char *fmt, va_list ap)
continue;
case 's':
if (precision < 0)
precision = INT_MAX;
s = va_arg(args, char *);
if (!s)
s = precision < 6 ? "" : "(null)";
len = strnlen(s, precision);
if (!(flags & LEFT))
......
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