Skip to content

Commit a7430b3

Browse files
authored
Merge pull request #8930 from kojiws/check_shift_counts
Clarify the len range on SetShortInt()
2 parents f713882 + b734c47 commit a7430b3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

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)