efi/printf: Fix minor bug in precision handling
authorArvind Sankar <nivedita@alum.mit.edu>
Mon, 18 May 2020 19:07:01 +0000 (15:07 -0400)
committerArd Biesheuvel <ardb@kernel.org>
Tue, 19 May 2020 08:31:25 +0000 (10:31 +0200)
A negative precision should be ignored completely, and the presence of a
valid precision should turn off the 0 flag.

Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Link: https://lore.kernel.org/r/20200518190716.751506-10-nivedita@alum.mit.edu
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
drivers/firmware/efi/libstub/vsprintf.c

index fb9eb83f1728d67d2a4b1305abf8fb7c432da52b..00123d5f402f64a7a3b27c890cceee1374a163fa 100644 (file)
@@ -279,9 +279,11 @@ int vsprintf(char *buf, const char *fmt, va_list args)
                                ++fmt;
                                /* it's the next argument */
                                precision = va_arg(args, int);
-                       }
-                       if (precision < 0)
+                       } else {
                                precision = 0;
+                       }
+                       if (precision >= 0)
+                               flags &= ~ZEROPAD;
                }
 
                /* get the conversion qualifier */