Skip to content

Commit d359f42

Browse files
committed
set *inLen = outLen if output == NULL, if != NULL, check that outLen <= *inLen before assigning *inLen = outLen
1 parent 6ebd967 commit d359f42

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

wolfcrypt/src/asn.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12912,15 +12912,16 @@ static int DsaKeyIntsToDer(DsaKey* key, byte* output, word32* inLen,
1291212912
seqSz = SetSequence(verSz + intTotalLen, seq);
1291312913

1291412914
outLen = seqSz + verSz + intTotalLen;
12915-
*inLen = outLen;
1291612915
if (output == NULL) {
12916+
*inLen = outLen;
1291712917
FreeTmpDsas(tmps, key->heap, ints);
1291812918
return WC_NO_ERR_TRACE(LENGTH_ONLY_E);
1291912919
}
1292012920
if (outLen > *inLen) {
1292112921
FreeTmpDsas(tmps, key->heap, ints);
1292212922
return BAD_FUNC_ARG;
1292312923
}
12924+
*inLen = outLen;
1292412925

1292512926
/* write to output */
1292612927
XMEMCPY(output, seq, seqSz);

0 commit comments

Comments
 (0)