crypto/bio/bio_print.c: '-' flag has priority over '0'

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)
This commit is contained in:
Eugene Syromiatnikov 2025-08-05 15:21:32 +02:00 committed by Neil Horman
parent 0f107c709c
commit 95af148e14
1 changed files with 3 additions and 3 deletions

View 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) {