]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Remove dead code in b64_write
authorNeil Horman <nhorman@openssl.org>
Tue, 30 Dec 2025 16:39:41 +0000 (11:39 -0500)
committerNeil Horman <nhorman@openssl.org>
Sun, 4 Jan 2026 22:51:49 +0000 (17:51 -0500)
recent updates triggered this coverity issues:
https://scan5.scan.coverity.com/#/project-view/60762/10222?selectedIssue=1677834

Because ret is initalized to zero, and checked prior to any further
update, the first return statement in this change is unreachable

Further the return ret == 0 ? i : ret statement makes teh setting of
buf_len and buf_off unreachable.

Remove all of this unreachable code

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 ff5c4e41ed2ea29f93547dfb1102f34e9ce65e3c..0079268e46d10f4b4bfcf0bb9258a370ef66f989 100644 (file)
@@ -407,17 +407,13 @@ static int b64_write(BIO *b, const char *in, int inl)
     int n_bytes_enc = 0;
     if (!EVP_EncodeUpdate(ctx->base64, encoded, &n_bytes_enc,
             (unsigned char *)in, inl)) {
-        if (ret == 0)
-            return -1;
-        return ret;
+        return -1;
     }
     ret += inl;
     i = BIO_write(next, encoded, n_bytes_enc);
     if (i <= 0) {
         BIO_copy_next_retry(b);
         return ret == 0 ? i : ret;
-        ctx->buf_len = 0;
-        ctx->buf_off = 0;
     }
     return ret;
 }