Merge pull request #8930 from kojiws/check_shift_counts

Clarify the len range on SetShortInt()
This commit is contained in:
Sean Parkinson
2025-06-27 09:46:42 +10:00
committed by GitHub

View File

@@ -3259,6 +3259,10 @@ int SetShortInt(byte* output, word32* inOutIdx, word32 number, word32 maxIdx)
else else
len = BytePrecision(number); 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)) { if (number >> (WOLFSSL_BIT_SIZE * len - 1)) {
/* Need one byte of zero value not to be negative number */ /* Need one byte of zero value not to be negative number */
extraByte = 1; extraByte = 1;