From b810bba09b8964f4b2253230e064777a7205e56d Mon Sep 17 00:00:00 2001 From: Aidan Keefe Date: Tue, 9 Jun 2026 11:54:44 -0600 Subject: [PATCH] added case to handel when second arc of byte encoding is greater than 39 when first arc is 2 --- wolfcrypt/src/asn.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/wolfcrypt/src/asn.c b/wolfcrypt/src/asn.c index 00be607506..908efbf98c 100644 --- a/wolfcrypt/src/asn.c +++ b/wolfcrypt/src/asn.c @@ -37073,6 +37073,10 @@ static int EncodedDottedForm(const byte* in, word32 inSz, word32* out, return BAD_FUNC_ARG; } + if (*outSz < 2) { + return BUFFER_E; + } + /* decode bytes */ while (inSz--) { t = (t << 7) | (in[x] & 0x7F); @@ -37081,8 +37085,15 @@ static int EncodedDottedForm(const byte* in, word32 inSz, word32* out, return BUFFER_E; } if (y == 0) { - out[0] = (word16)(t / 40); - out[1] = (word16)(t % 40); + /* Special case for when first arc is 2 */ + if (t < 80) { + out[0] = t / 40; + out[1] = t % 40; + } + else { + out[0] = 2; + out[1] = t - 80; + } y = 2; } else {