Remove dead code in b64_write

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)
This commit is contained in:
Neil Horman
2025-12-30 11:39:41 -05:00
parent 61c876198d
commit b6ab93b783

View 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;
}