@@ -41804,7 +41804,7 @@ static int ParseCRL_Extensions(DecodedCRL* dcrl, const byte* buf,
4180441804 WOLFSSL_MSG("\tcouldn't parse CRL number extension");
4180541805 return ret;
4180641806 }
41807- else {
41807+ else if (length <= CRL_MAX_NUM_SZ) {
4180841808 DECL_MP_INT_SIZE_DYN(m, CRL_MAX_NUM_SZ_BITS,
4180941809 CRL_MAX_NUM_SZ_BITS);
4181041810 NEW_MP_INT_SIZE(m, CRL_MAX_NUM_SZ_BITS, NULL,
@@ -41825,15 +41825,7 @@ static int ParseCRL_Extensions(DecodedCRL* dcrl, const byte* buf,
4182541825
4182641826 if (ret != MP_OKAY)
4182741827 ret = BUFFER_E;
41828- /* Check CRL number size
41829- * if it exceeds CRL_MAX_NUM_SZ(octets)
41830- * and CRL_MAX_NUM_HEX_STR_SZ(hex string)
41831- */
41832- if (((needed = mp_unsigned_bin_size(m)) > CRL_MAX_NUM_SZ) ||
41833- ((needed * 2 + 1) > CRL_MAX_NUM_HEX_STR_SZ)) {
41834- WOLFSSL_MSG("CRL number exceeds limitation.");
41835- ret = BUFFER_E;
41836- }
41828+
4183741829 if (ret == MP_OKAY && mp_toradix(m, (char*)dcrl->crlNumber,
4183841830 MP_RADIX_HEX) != MP_OKAY)
4183941831 ret = BUFFER_E;
@@ -41846,6 +41838,9 @@ static int ParseCRL_Extensions(DecodedCRL* dcrl, const byte* buf,
4184641838
4184741839 if (ret != MP_OKAY)
4184841840 return ret;
41841+ } else {
41842+ WOLFSSL_MSG("CRL number exceeds limitation");
41843+ ret = BUFFER_E;
4184941844 }
4185041845 }
4185141846 }
@@ -41871,7 +41866,6 @@ static int ParseCRL_Extensions(DecodedCRL* dcrl, const byte* buf, word32 idx,
4187141866 word32 maxIdx)
4187241867{
4187341868 DECL_ASNGETDATA(dataASN, certExtASN_Length);
41874- int needed;
4187541869 int ret = 0;
4187641870 /* Track if we've seen these extensions already */
4187741871 word32 seenAuthKey = 0;
@@ -41949,16 +41943,16 @@ static int ParseCRL_Extensions(DecodedCRL* dcrl, const byte* buf, word32 idx,
4194941943 }
4195041944
4195141945 if (ret == 0) {
41952- ret = GetInt(m, buf, &localIdx, maxIdx) ;
41953- }
41954- /* Check CRL number size
41955- * if it exceeds CRL_MAX_NUM_SZ(octets)
41956- * and CRL_MAX_NUM_HEX_STR_SZ(hex string)
41957- */
41958- if (((needed = mp_unsigned_bin_size(m)) > CRL_MAX_NUM_SZ) ||
41959- ((needed * 2 + 1) > CRL_MAX_NUM_HEX_STR_SZ) ) {
41960- WOLFSSL_MSG("CRL number exceeds limitation." );
41961- ret = BUFFER_E;
41946+ int crlNumLen = 0 ;
41947+ word32 tmpIdx = localIdx;
41948+ ret = GetASNInt(buf, &tmpIdx, &crlNumLen, maxIdx);
41949+ if (ret == 0 && (crlNumLen > CRL_MAX_NUM_SZ)) {
41950+ WOLFSSL_MSG("CRL number exceeds limitation");
41951+ ret = BUFFER_E;
41952+ }
41953+ if (ret == 0 ) {
41954+ ret = GetInt(m, buf, &localIdx, maxIdx );
41955+ }
4196241956 }
4196341957 if (ret == 0 && mp_toradix(m, (char*)dcrl->crlNumber,
4196441958 MP_RADIX_HEX) != MP_OKAY)
0 commit comments