Skip to content

Commit d8757a5

Browse files
authored
Merge pull request #7717 from JacobBarthelmeh/coverity
Some additional Coverity touch ups
2 parents d5016d4 + fee9788 commit d8757a5

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

src/ssl_asn1.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,11 @@ static int wolfssl_i2d_asn1_item(void** item, int type, byte* buf)
247247
len = 0;
248248
}
249249

250+
if (len < 0) {
251+
len = 0; /* wolfSSL_i2d_ASN1_INTEGER can return a value less than 0
252+
* on error */
253+
}
254+
250255
return len;
251256
}
252257

tests/api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65656,7 +65656,7 @@ static int test_EccSigFailure_cm(void)
6565665656
size_t cert_sz = 0;
6565765657

6565865658
ExpectIntEQ(load_file(server_cert, &cert_buf, &cert_sz), 0);
65659-
if (cert_buf != NULL) {
65659+
if (cert_buf != NULL && cert_sz > 0) {
6566065660
/* corrupt DER - invert last byte, which is signature */
6566165661
cert_buf[cert_sz-1] = ~cert_buf[cert_sz-1];
6566265662

wolfcrypt/src/evp.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3283,6 +3283,8 @@ int wolfSSL_EVP_PKEY_bits(const WOLFSSL_EVP_PKEY *pkey)
32833283
if (pkey == NULL) return 0;
32843284
WOLFSSL_ENTER("wolfSSL_EVP_PKEY_bits");
32853285
if ((bytes = wolfSSL_EVP_PKEY_size((WOLFSSL_EVP_PKEY*)pkey)) ==0) return 0;
3286+
if (bytes < 0)
3287+
return 0;
32863288
return bytes*8;
32873289
}
32883290

0 commit comments

Comments
 (0)