]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
bio_print.c: Delete unreachable code at lines 710 and 711
authorMrRurikov <96385824+MrRurikov@users.noreply.github.com>
Thu, 29 Jun 2023 14:06:08 +0000 (17:06 +0300)
committerTomas Mraz <tomas@openssl.org>
Tue, 25 Jul 2023 10:38:31 +0000 (12:38 +0200)
CLA: trivial

The purpose of adding the conditional operator on line 710 is to check
if the value of the variable 'fplace' exceeds the size of the array
'fconvert', and to reduce the value of 'fplace' by 1, so that later on
we can set the value to zero of the array element with the index 'fplace'
and not make any calls beyond the array edges.

However, the condition on line 710 will always be false, because
the size of 'fconvert' is strictly specified at the beginning of
the 'fmtfp()' function (line 571), so it is reasonable to remove
this conditional operator, as well as the unreachable decrementation
code of the variable 'fplace'.

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21325)

crypto/bio/bio_print.c

index 34787a29a7b7a973099c26a03541e54d0403fd75..1d8fa1c44df4f97e32c3177431a4039a9828e7b7 100644 (file)
@@ -707,8 +707,6 @@ fmtfp(char **sbuffer,
         fracpart = (fracpart / 10);
     }
 
-    if (fplace == sizeof(fconvert))
-        fplace--;
     fconvert[fplace] = 0;
 
     /* convert exponent part */