From d359f420aba861ebb7282a159faa9558d8c948e2 Mon Sep 17 00:00:00 2001 From: Ruby Martin Date: Thu, 12 Mar 2026 10:25:14 -0600 Subject: [PATCH] set *inLen = outLen if output == NULL, if != NULL, check that outLen <= *inLen before assigning *inLen = outLen --- wolfcrypt/src/asn.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wolfcrypt/src/asn.c b/wolfcrypt/src/asn.c index 8bc8d76605..558179833b 100644 --- a/wolfcrypt/src/asn.c +++ b/wolfcrypt/src/asn.c @@ -12912,8 +12912,8 @@ static int DsaKeyIntsToDer(DsaKey* key, byte* output, word32* inLen, seqSz = SetSequence(verSz + intTotalLen, seq); outLen = seqSz + verSz + intTotalLen; - *inLen = outLen; if (output == NULL) { + *inLen = outLen; FreeTmpDsas(tmps, key->heap, ints); return WC_NO_ERR_TRACE(LENGTH_ONLY_E); } @@ -12921,6 +12921,7 @@ static int DsaKeyIntsToDer(DsaKey* key, byte* output, word32* inLen, FreeTmpDsas(tmps, key->heap, ints); return BAD_FUNC_ARG; } + *inLen = outLen; /* write to output */ XMEMCPY(output, seq, seqSz);