Skip to content

Commit a9c0689

Browse files
committed
crypto: fix return type prob reported by coverity
Coverity correctly reported that the value returned by BIO_get_mem_data could be negative and the type provided for the return value was unsigned. Fix up the type and check. Signed-off-by: Michael Dawson <mdawson@devrus.com> PR-URL: #42135 Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Darshan Sen <raisinten@gmail.com>
1 parent 3ba4124 commit a9c0689

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/crypto/crypto_common.cc

+3-2
Original file line numberDiff line numberDiff line change
@@ -741,9 +741,10 @@ static bool PrintGeneralName(const BIOPointer& out, const GENERAL_NAME* gen) {
741741
return false;
742742
}
743743
char* oline = nullptr;
744-
size_t n_bytes = BIO_get_mem_data(tmp.get(), &oline);
744+
long n_bytes = BIO_get_mem_data(tmp.get(), &oline); // NOLINT(runtime/int)
745+
CHECK_GE(n_bytes, 0);
745746
CHECK_IMPLIES(n_bytes != 0, oline != nullptr);
746-
PrintAltName(out, oline, n_bytes, true, nullptr);
747+
PrintAltName(out, oline, static_cast<size_t>(n_bytes), true, nullptr);
747748
} else if (gen->type == GEN_IPADD) {
748749
BIO_printf(out.get(), "IP Address:");
749750
const ASN1_OCTET_STRING* ip = gen->d.ip;

0 commit comments

Comments
 (0)