Skip to content

Commit b2750c8

Browse files
committed
Address copilot feedback
1 parent b5ed5e4 commit b2750c8

3 files changed

Lines changed: 16 additions & 5 deletions

File tree

src/tls13.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8722,6 +8722,8 @@ static int WriteCSRToBuffer(WOLFSSL* ssl, DerBuffer** certExts,
87228722
if (tmpSz > (OPAQUE8_LEN + OPAQUE24_LEN) &&
87238723
certExts[extIdx] == NULL) {
87248724
/* csr extension is not zero */
8725+
if (tmpSz > 0xFFFF)
8726+
return BUFFER_E;
87258727
extSz[extIdx] = (word16)tmpSz;
87268728

87278729
ret = AllocDer(&certExts[extIdx], extSz[extIdx] + ex_offset,

wolfcrypt/src/asn.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41520,13 +41520,19 @@ static int DecodeOcspReqExtensions(const byte* source, word32 sz,
4152041520
int length = (int)dataASN[CERTEXTASN_IDX_VAL].length;
4152141521

4152241522
if (oid == OCSP_NONCE_OID) {
41523-
/* Extract nonce data - get data inside inner OCTET_STRING */
41524-
ret = GetOctetString(source, &idx, &length, sz);
41523+
/* Parse inner OCTET STRING from the extension value buffer
41524+
* using a local index to avoid relying on the outer idx. */
41525+
const byte* extData = dataASN[CERTEXTASN_IDX_VAL].data.ref.data;
41526+
word32 extDataSz = dataASN[CERTEXTASN_IDX_VAL].data.ref.length;
41527+
word32 localIdx = 0;
41528+
int innerLen = (int)extDataSz;
41529+
41530+
ret = GetOctetString(extData, &localIdx, &innerLen, extDataSz);
4152541531
if (ret >= 0) {
4152641532
ret = 0;
41527-
if (length <= (int)sizeof(req->nonce)) {
41528-
XMEMCPY(req->nonce, source + idx, (size_t)length);
41529-
req->nonceSz = length;
41533+
if (innerLen <= (int)sizeof(req->nonce)) {
41534+
XMEMCPY(req->nonce, extData + localIdx, (size_t)innerLen);
41535+
req->nonceSz = innerLen;
4153041536
}
4153141537
else {
4153241538
/* Nonce too large */

wolfssl/wolfcrypt/settings.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5034,6 +5034,9 @@ extern void uITRON4_free(void *p) ;
50345034
#ifndef WOLFSSL_CERT_GEN
50355035
#error "HAVE_OCSP_RESPONDER requires WOLFSSL_CERT_GEN"
50365036
#endif
5037+
#ifdef NO_SHA
5038+
#error "HAVE_OCSP_RESPONDER requires SHA-1 (NO_SHA is defined)"
5039+
#endif
50375040
#endif
50385041

50395042
#ifdef __cplusplus

0 commit comments

Comments
 (0)