From 7eb18e768dbec07dbac7e883629c5d5875c7f7b8 Mon Sep 17 00:00:00 2001 From: Eugene Syromiatnikov Date: Tue, 5 Aug 2025 14:53:28 +0200 Subject: [PATCH] crypto/bio/bio_print.c: handle negative width argument MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Per [1]: A negative field width is taken as a '-' flag followed by a positive field width. So, printf("%-*d", -12, 34) should lead to a 123-wide left-aligned output, "34 ". [1] https://pubs.opengroup.org/onlinepubs/9799919799//functions/printf.html Signed-off-by: Eugene Syromiatnikov Reviewed-by: Saša Nedvědický Reviewed-by: Neil Horman (Merged from https://github.com/openssl/openssl/pull/28177) --- crypto/bio/bio_print.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crypto/bio/bio_print.c b/crypto/bio/bio_print.c index 1a0b268501..67f24604a7 100644 --- a/crypto/bio/bio_print.c +++ b/crypto/bio/bio_print.c @@ -155,6 +155,10 @@ _dopr(char **sbuffer, ch = *format++; } else if (ch == '*') { min = va_arg(args, int); + if (min < 0) { + flags |= DP_F_MINUS; + min = -min; + } ch = *format++; state = DP_S_DOT; } else