]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
crypto/bio/bio_print.c: '-' flag has priority over '0'
authorEugene Syromiatnikov <esyr@openssl.org>
Tue, 5 Aug 2025 13:21:32 +0000 (15:21 +0200)
committerNeil Horman <nhorman@openssl.org>
Fri, 29 Aug 2025 16:18:30 +0000 (12:18 -0400)
Per [1]:

    If the '0' and '-' flags both appear, the '0' flag is ignored.

[1] https://pubs.opengroup.org/onlinepubs/9799919799//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 7600c366833b79ffc102336fa9172a10ba037c3d..6f67a870b6511609d937f98c7c31f20af037d7c1 100644 (file)
@@ -506,12 +506,12 @@ fmtint(char **sbuffer,
         zpadlen = 0;
     if (spadlen < 0)
         spadlen = 0;
-    if (flags & DP_F_ZERO) {
+    if (flags & DP_F_MINUS) {
+        spadlen = -spadlen;
+    } else if (flags & DP_F_ZERO) {
         zpadlen = OSSL_MAX(zpadlen, spadlen);
         spadlen = 0;
     }
-    if (flags & DP_F_MINUS)
-        spadlen = -spadlen;
 
     /* spaces */
     while (spadlen > 0) {