]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
crypto/bio/bio_print.c: correctly print 0X prefix for X conversion
authorEugene Syromiatnikov <esyr@openssl.org>
Fri, 25 Jul 2025 17:00:22 +0000 (19:00 +0200)
committerNeil Horman <nhorman@openssl.org>
Fri, 29 Aug 2025 16:18:30 +0000 (12:18 -0400)
Per [1]:

   For x or X conversion specifiers, a non-zero result shall have 0x (or 0X)
   prefixed to it.

[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 f6db6d3bfc125bd740b4d5a62fc662148687e904..1a0b2685018f1fbf47944978abecc849ec3449c8 100644 (file)
@@ -473,7 +473,7 @@ fmtint(char **sbuffer,
         if (base == 8)
             prefix = "0";
         if (base == 16)
-            prefix = "0x";
+            prefix = flags & DP_F_UP ? "0X" : "0x";
     }
     if (flags & DP_F_UP)
         caps = 1;