Skip to content

Commit 03216f5

Browse files
authored
enforce OCSP_MAX_RESPONSE_SIZE (#38)
Introduce a hard limit of 64 KB for OCSP responses
1 parent b7b16f9 commit 03216f5

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

native/src/sslutils.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -892,6 +892,7 @@ static OCSP_RESPONSE *parse_ocsp_resp(char *buf, int len)
892892
/* Reads the response from the APR socket to a buffer, and parses the buffer to
893893
return the OCSP response */
894894
#define BUFFER_SIZE 512
895+
#define OCSP_MAX_RESPONSE_SIZE 65536
895896
static OCSP_RESPONSE *ocsp_get_resp(apr_pool_t *mp, apr_socket_t *sock)
896897
{
897898
int buflen;
@@ -914,7 +915,10 @@ static OCSP_RESPONSE *ocsp_get_resp(apr_pool_t *mp, apr_socket_t *sock)
914915
readlen = sizeof(tmpbuf);
915916
rv = apr_socket_recv(sock, tmpbuf, &readlen);
916917
if (rv == APR_SUCCESS) { /* if we have read something .. we can put it in the buffer*/
917-
if ((totalread + readlen) >= buflen) {
918+
if ((totalread + readlen) > OCSP_MAX_RESPONSE_SIZE) {
919+
apr_pool_destroy(p);
920+
return NULL;
921+
} else if ((totalread + readlen) >= buflen) {
918922
buf = apr_xrealloc(buf, buflen, buflen * 2, p);
919923
if (buf == NULL) {
920924
apr_pool_destroy(p);

0 commit comments

Comments
 (0)