Check the len range stricter

pull/8930/head
Koji Takeda 2025-06-26 17:48:52 +09:00
parent 981ba4b14c
commit b734c47cc9
1 changed files with 4 additions and 0 deletions

View File

@ -3259,6 +3259,10 @@ int SetShortInt(byte* output, word32* inOutIdx, word32 number, word32 maxIdx)
else
len = BytePrecision(number);
/* clarify the len range to prepare for the next right bit shifting */
if (len < 1 || len > sizeof(number)) {
return ASN_PARSE_E;
}
if (number >> (WOLFSSL_BIT_SIZE * len - 1)) {
/* Need one byte of zero value not to be negative number */
extraByte = 1;