]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
crypto/bio/bio_print.c: reset max to zero if empty precision string is provided
authorEugene Syromiatnikov <esyr@openssl.org>
Thu, 14 Aug 2025 17:15:09 +0000 (19:15 +0200)
committerNeil Horman <nhorman@openssl.org>
Fri, 29 Aug 2025 16:18:30 +0000 (12:18 -0400)
Per [1]:

    a null digit string is treated as zero.

[1] https://pubs.opengroup.org/onlinepubs/9699919799/functions/printf.html

Signed-off-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28177)

crypto/bio/bio_print.c

index f8031743ac1fd3eb39a8887a7ad8713d7d28de27..3cb4d285574dc2f18093bdb1319d976b81f477a4 100644 (file)
@@ -182,8 +182,11 @@ _dopr(char **sbuffer,
                 max = va_arg(args, int);
                 ch = *format++;
                 state = DP_S_MOD;
-            } else
+            } else {
+                if (max < 0)
+                    max = 0;
                 state = DP_S_MOD;
+            }
             break;
         case DP_S_MOD:
             switch (ch) {