Skip to content

Commit b734c47

Browse files
committed
Check the len range stricter
1 parent 981ba4b commit b734c47

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

wolfcrypt/src/asn.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3259,6 +3259,10 @@ int SetShortInt(byte* output, word32* inOutIdx, word32 number, word32 maxIdx)
32593259
else
32603260
len = BytePrecision(number);
32613261

3262+
/* clarify the len range to prepare for the next right bit shifting */
3263+
if (len < 1 || len > sizeof(number)) {
3264+
return ASN_PARSE_E;
3265+
}
32623266
if (number >> (WOLFSSL_BIT_SIZE * len - 1)) {
32633267
/* Need one byte of zero value not to be negative number */
32643268
extraByte = 1;

0 commit comments

Comments
 (0)