Skip to content

Commit 5d0e050

Browse files
Ensure ProcessChainOCSPRequest does not exceed the length of the cert chain.
Thanks to Zou Dikai for the report.
1 parent d0a0c32 commit 5d0e050

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

src/tls.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3614,6 +3614,12 @@ int ProcessChainOCSPRequest(WOLFSSL* ssl)
36143614

36153615
if (chain && chain->buffer) {
36163616
while (ret == 0 && pos + OPAQUE24_LEN < chain->length) {
3617+
if (i >= MAX_CERT_EXTENSIONS) {
3618+
WOLFSSL_MSG("OCSP request cert chain exceeds maximum length.");
3619+
ret = MAX_CERT_EXTENSIONS_ERR;
3620+
break;
3621+
}
3622+
36173623
c24to32(chain->buffer + pos, &der.length);
36183624
pos += OPAQUE24_LEN;
36193625
der.buffer = chain->buffer + pos;

src/tls13.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8898,7 +8898,7 @@ static int WriteCSRToBuffer(WOLFSSL* ssl, DerBuffer** certExts,
88988898
DerBuffer* der;
88998899

89008900
if (extSz_num > MAX_CERT_EXTENSIONS)
8901-
return BAD_FUNC_ARG;
8901+
return MAX_CERT_EXTENSIONS_ERR;
89028902

89038903
ext = TLSX_Find(ssl->extensions, TLSX_STATUS_REQUEST);
89048904
csr = ext ? (CertificateStatusRequest*)ext->data : NULL;
@@ -9152,7 +9152,7 @@ static int SendTls13Certificate(WOLFSSL* ssl)
91529152
return ret;
91539153

91549154
if ((word16)(1 + ssl->buffers.certChainCnt) > MAX_CERT_EXTENSIONS)
9155-
ret = BAD_FUNC_ARG;
9155+
ret = MAX_CERT_EXTENSIONS_ERR;
91569156
if (ret == 0)
91579157
ret = WriteCSRToBuffer(ssl, &ssl->buffers.certExts[0], &extSz[0],
91589158
1 /* +1 for leaf */ + (word16)ssl->buffers.certChainCnt);

0 commit comments

Comments
 (0)