summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorArvind Sankar <nivedita@alum.mit.edu>2020-05-18 15:07:05 -0400
committerArd Biesheuvel <ardb@kernel.org>2020-05-19 10:31:50 +0200
commitfb031937a86874e6d663542bdbd83e310c13610e (patch)
tree99c883ef67c70364f3234b95cf9f5ac2da168198 /drivers
parentdec6119952eab7257624de5bd116a9e301ead5b7 (diff)
downloadlinux-fb031937a86874e6d663542bdbd83e310c13610e.tar.bz2
efi/printf: Handle null string input
Print "(null)" for 's' if the input is a NULL pointer. Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu> Link: https://lore.kernel.org/r/20200518190716.751506-14-nivedita@alum.mit.edu Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/firmware/efi/libstub/vsprintf.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/firmware/efi/libstub/vsprintf.c b/drivers/firmware/efi/libstub/vsprintf.c
index 27685c726c64..d427a7b1ef64 100644
--- a/drivers/firmware/efi/libstub/vsprintf.c
+++ b/drivers/firmware/efi/libstub/vsprintf.c
@@ -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))