@@ -549,7 +549,7 @@ static word32 SizeASNLength(word32 length)
549549 * @param [in] heap Dynamic memory allocation hint.
550550 */
551551 #define ALLOC_ASNGETDATA(name, cnt, err, heap) \
552- (void)(cnt); (void)(err); (void)(heap); WC_DO_NOTHING
552+ do { (void)(cnt); (void)(err); (void)(heap); } while (0)
553553
554554 /* Clears the memory of the dynamic BER encoding data.
555555 *
@@ -567,7 +567,7 @@ static word32 SizeASNLength(word32 length)
567567 * @param [in] heap Dynamic memory allocation hint.
568568 */
569569 #define FREE_ASNGETDATA(name, heap) \
570- (void)(name); (void)(heap); WC_DO_NOTHING
570+ do { (void)(name); (void)(heap); } while (0)
571571
572572 /* Declare the variable that is the dynamic data for encoding DER data.
573573 *
@@ -585,7 +585,7 @@ static word32 SizeASNLength(word32 length)
585585 * @param [in] heap Dynamic memory allocation hint.
586586 */
587587 #define ALLOC_ASNSETDATA(name, cnt, err, heap) \
588- (void)(cnt); (void)(err); (void)(heap); WC_DO_NOTHING
588+ do { (void)(cnt); (void)(err); (void)(heap); } while (0)
589589
590590 /* Clears the memory of the dynamic BER encoding data.
591591 *
@@ -603,7 +603,7 @@ static word32 SizeASNLength(word32 length)
603603 * @param [in] heap Dynamic memory allocation hint.
604604 */
605605 #define FREE_ASNSETDATA(name, heap) \
606- (void)(name); (void)(heap); WC_DO_NOTHING
606+ do { (void)(name); (void)(heap); } while (0)
607607#endif
608608
609609
@@ -41385,6 +41385,8 @@ int EncodeOcspRequest(OcspRequest* req, byte* output, word32 size)
4138541385
4138641386 algoSz = SetAlgoID(req->hashAlg, algoArray, oidHashType, 0);
4138741387 keyIdSz = wc_HashGetDigestSize(wc_OidGetHash(req->hashAlg));
41388+ if (keyIdSz <= 0 || keyIdSz > WC_MAX_DIGEST_SIZE)
41389+ return BAD_FUNC_ARG;
4138841390
4138941391 issuerSz = SetDigest(req->issuerHash, keyIdSz, issuerArray);
4139041392 issuerKeySz = SetDigest(req->issuerKeyHash, keyIdSz, issuerKeyArray);
@@ -41451,11 +41453,17 @@ int EncodeOcspRequest(OcspRequest* req, byte* output, word32 size)
4145141453
4145241454 CALLOC_ASNSETDATA(dataASN, ocspRequestASN_Length, ret, req->heap);
4145341455
41456+ if (ret == 0) {
41457+ int digestSz = wc_HashGetDigestSize(wc_OidGetHash(req->hashAlg));
41458+ if (digestSz <= 0)
41459+ ret = BAD_FUNC_ARG;
41460+ else
41461+ keyIdSz = (word32)digestSz;
41462+ }
4145441463 if (ret == 0) {
4145541464 /* Set OID of hash algorithm use on issuer and key. */
4145641465 SetASN_OID(&dataASN[OCSPREQUESTASN_IDX_TBS_REQ_HASH_OID], req->hashAlg,
4145741466 oidHashType);
41458- keyIdSz = (word32)wc_HashGetDigestSize(wc_OidGetHash(req->hashAlg));
4145941467 /* Set issuer, issuer key hash and serial number of certificate being
4146041468 * checked. */
4146141469 SetASN_Buffer(&dataASN[OCSPREQUESTASN_IDX_TBS_REQ_ISSUER],
0 commit comments