mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-07-05 14:10:51 +02:00
Merge pull request #10458 from philljj/fix_GetShortInt
asn: fix GetShortInt for asn original.
This commit is contained in:
+14
-1
@@ -753,7 +753,20 @@ int test_GetSetShortInt(void)
|
||||
ExpectIntEQ(GetShortInt(valDer, &idx, &value, 6),
|
||||
WC_NO_ERR_TRACE(ASN_EXPECT_0_E));
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (!defined(HAVE_SELFTEST) && !defined(HAVE_FIPS)) || \
|
||||
(defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION > 2))
|
||||
/* zero length value. should return ASN_PARSE_E */
|
||||
{
|
||||
word32 idx = 0;
|
||||
int value = 0;
|
||||
valDer[0] = ASN_INTEGER;
|
||||
valDer[1] = 0x00;
|
||||
ExpectIntEQ(GetShortInt(valDer, &idx, &value, 2),
|
||||
WC_NO_ERR_TRACE(ASN_PARSE_E));
|
||||
}
|
||||
#endif /* */
|
||||
#endif /* !NO_PWDBASED || WOLFSSL_ASN_EXTRA */
|
||||
#endif
|
||||
|
||||
return EXPECT_RESULT();
|
||||
|
||||
@@ -3465,6 +3465,13 @@ int GetShortInt(const byte* input, word32* inOutIdx, int* number, word32 maxIdx)
|
||||
if (len > 4)
|
||||
return ASN_PARSE_E;
|
||||
|
||||
/* to be consistent with GetASN_Integer */
|
||||
#if (!defined(HAVE_SELFTEST) && !defined(HAVE_FIPS)) || \
|
||||
(defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION > 2))
|
||||
if (len == 0)
|
||||
return ASN_PARSE_E;
|
||||
#endif
|
||||
|
||||
if (len + idx > maxIdx)
|
||||
return ASN_PARSE_E;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user