Skip to content

Commit 424af6e

Browse files
Merge pull request #9956 from rlm2002/coverity
20260311 Coverity changes
2 parents e5594a6 + d359f42 commit 424af6e

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

tests/quic.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -731,9 +731,13 @@ static void ext_dump(const byte *data, size_t data_len, int indent)
731731
word16 len16, etype, i;
732732

733733
printf("%*sextensions:\n", indent, " ");
734-
while (idx < data_len) {
734+
while (idx + 4 <= data_len) {
735735
ato16(&data[idx], &etype); /* extension type */
736736
ato16(&data[idx+2], &len16); /* extension length */
737+
if (idx + 4 + len16 > data_len) {
738+
printf(" unexpected extension length\n");
739+
break;
740+
}
737741
printf(" extension: %04x [", etype);
738742
for (i = 0; i < len16; ++i) {
739743
printf("%s0x%02x", (i? ", ": ""), data[idx+4+i]);

wolfcrypt/src/asn.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12932,15 +12932,16 @@ static int DsaKeyIntsToDer(DsaKey* key, byte* output, word32* inLen,
1293212932
seqSz = SetSequence(verSz + intTotalLen, seq);
1293312933

1293412934
outLen = seqSz + verSz + intTotalLen;
12935-
*inLen = outLen;
1293612935
if (output == NULL) {
12936+
*inLen = outLen;
1293712937
FreeTmpDsas(tmps, key->heap, ints);
1293812938
return WC_NO_ERR_TRACE(LENGTH_ONLY_E);
1293912939
}
1294012940
if (outLen > *inLen) {
1294112941
FreeTmpDsas(tmps, key->heap, ints);
1294212942
return BAD_FUNC_ARG;
1294312943
}
12944+
*inLen = outLen;
1294412945

1294512946
/* write to output */
1294612947
XMEMCPY(output, seq, seqSz);
@@ -18024,6 +18025,10 @@ static word32 SetAlgoIDImpl(int algoOID, byte* output, int type, int curveSz,
1802418025
word32 algoSz = 0;
1802518026

1802618027
CALLOC_ASNSETDATA(dataASN, algoIdASN_Length, ret, NULL);
18028+
if(ret < 0) {
18029+
/* Catch MEMORY_E */
18030+
return 0;
18031+
}
1802718032

1802818033
algoName = OidFromId((word32)algoOID, (word32)type, &algoSz);
1802918034
if (algoName == NULL) {
@@ -43470,7 +43475,7 @@ int wc_MakeCRL_ex(const byte* issuerDer, word32 issuerSz,
4347043475

4347143476
/* Signature AlgorithmIdentifier */
4347243477
algoSz = SetAlgoID(sigType, algoBuf, oidSigType, 0);
43473-
if (algoSz == 0)
43478+
if (algoSz == 0 || algoSz > MAX_ALGO_SZ)
4347443479
return ALGO_ID_E;
4347543480

4347643481
/* thisUpdate */

0 commit comments

Comments
 (0)