Blob Blame History Raw
From: Arvind Sankar <nivedita@alum.mit.edu>
Date: Mon, 18 May 2020 15:07:01 -0400
Subject: efi/printf: Fix minor bug in precision handling
Patch-mainline: v5.8-rc1
Git-commit: 77e48db04a02ebd00229281c26575979b0b465e0
References: jsc#SLE-16407

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>
Acked-by: Lee, Chun-Yi <jlee@suse.com>
---
 drivers/firmware/efi/libstub/vsprintf.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

--- a/drivers/firmware/efi/libstub/vsprintf.c
+++ b/drivers/firmware/efi/libstub/vsprintf.c
@@ -279,9 +279,11 @@ int vsprintf(char *buf, const char *fmt,
 				++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 */