Skip to content

Commit 8059fbd

Browse files
authored
Merge pull request #10129 from rlm2002/coverity_fix
03042026 Coverity tests fix
2 parents 9e199f3 + 5e79661 commit 8059fbd

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

tests/api/test_ossl_asn1.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,11 @@ int test_wolfSSL_ASN1_INTEGER_BN(void)
198198
}
199199
#if defined(WOLFSSL_QT) || defined(WOLFSSL_HAPROXY)
200200
ExpectNotNull(bn = ASN1_INTEGER_to_BN(ai, NULL));
201-
BN_free(bn);
202-
bn = NULL;
203201
#else
204-
ExpectNull(ASN1_INTEGER_to_BN(ai, NULL));
202+
ExpectNull(bn = ASN1_INTEGER_to_BN(ai, NULL));
205203
#endif
204+
BN_free(bn);
205+
bn = NULL;
206206

207207
if (ai != NULL) {
208208
ai->data[0] = 0x02; /* tag for ASN_INTEGER */
@@ -213,11 +213,11 @@ int test_wolfSSL_ASN1_INTEGER_BN(void)
213213
#if defined(WOLFSSL_QT) || defined(WOLFSSL_HAPROXY)
214214
/* Interpreted as a number 0x020403. */
215215
ExpectNotNull(bn = ASN1_INTEGER_to_BN(ai, NULL));
216-
BN_free(bn);
217-
bn = NULL;
218216
#else
219-
ExpectNull(ASN1_INTEGER_to_BN(ai, NULL));
217+
ExpectNull(bn = ASN1_INTEGER_to_BN(ai, NULL));
220218
#endif
219+
BN_free(bn);
220+
bn = NULL;
221221

222222
if (ai != NULL) {
223223
ai->data[0] = 0x02; /* tag for ASN_INTEGER */

tests/api/test_x509.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,9 @@ static int craft_malicious_time_cert(const byte* orig, int origSz,
502502

503503
notBeforeLenOff = validityOff + 3; /* the 0x0D byte */
504504
notBeforeDataEnd = notBeforeLenOff + 1 + 13; /* tag(1) was at +2, data starts at +4 */
505+
if (notBeforeDataEnd >= origSz) {
506+
return -1;
507+
}
505508

506509
/* Build the new buffer:
507510
* [0 .. notBeforeLenOff-1] unchanged prefix

0 commit comments

Comments
 (0)