mirror of https://github.com/openssl/openssl.git
crypto/bio/bio_print.c: fix space padding calculation
Sign, prefix, and zero padding should count towards precision. 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:
parent
95af148e14
commit
badbcc6631
|
@ -500,16 +500,16 @@ fmtint(char **sbuffer,
|
||||||
* if necessary, to force the first digit of the result to be a zero
|
* if necessary, to force the first digit of the result to be a zero
|
||||||
*/
|
*/
|
||||||
zpadlen = max - place - (prefix == oct_prefix);
|
zpadlen = max - place - (prefix == oct_prefix);
|
||||||
spadlen =
|
|
||||||
min - OSSL_MAX(max, place) - (signvalue ? 1 : 0) - (int)strlen(prefix);
|
|
||||||
if (zpadlen < 0)
|
if (zpadlen < 0)
|
||||||
zpadlen = 0;
|
zpadlen = 0;
|
||||||
|
spadlen =
|
||||||
|
min - OSSL_MAX(max, place + zpadlen + (signvalue ? 1 : 0) + (int)strlen(prefix));
|
||||||
if (spadlen < 0)
|
if (spadlen < 0)
|
||||||
spadlen = 0;
|
spadlen = 0;
|
||||||
if (flags & DP_F_MINUS) {
|
if (flags & DP_F_MINUS) {
|
||||||
spadlen = -spadlen;
|
spadlen = -spadlen;
|
||||||
} else if (flags & DP_F_ZERO) {
|
} else if (flags & DP_F_ZERO) {
|
||||||
zpadlen = OSSL_MAX(zpadlen, spadlen);
|
zpadlen = zpadlen + spadlen;
|
||||||
spadlen = 0;
|
spadlen = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue