]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Fix more dead code in b64_write
authorNeil Horman <nhorman@openssl.org>
Tue, 30 Dec 2025 18:52:38 +0000 (13:52 -0500)
committerNeil Horman <nhorman@openssl.org>
Sun, 4 Jan 2026 22:51:56 +0000 (17:51 -0500)
https://scan5.scan.coverity.com/#/project-view/60762/10222?selectedIssue=1677831

reports more dead code in b64_write

ret is incremented by inl in b64_write prior to being tested for zero.
Since inl is previously tested for being <= 0, and returns if it is, ret
must be at least 1 during the test, making the trinary test dead code.

Just return -1 here.

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29525)

crypto/evp/bio_b64.c

index 0079268e46d10f4b4bfcf0bb9258a370ef66f989..7b3decd2bfd315a70ac032a10e9920d25f98a766 100644 (file)
@@ -411,10 +411,8 @@ static int b64_write(BIO *b, const char *in, int inl)
     }
     ret += inl;
     i = BIO_write(next, encoded, n_bytes_enc);
-    if (i <= 0) {
+    if (i <= 0)
         BIO_copy_next_retry(b);
-        return ret == 0 ? i : ret;
-    }
     return ret;
 }