forked from wolfSSL/wolfssl
Maintenance: OCSP
1. Add some minimum bounds checking on the HTTP responses as some can end up being too short.
This commit is contained in:
12
src/wolfio.c
12
src/wolfio.c
@ -1102,6 +1102,12 @@ int wolfIO_HttpProcessResponse(int sfd, const char** appStrList,
|
|||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case phr_init:
|
case phr_init:
|
||||||
|
if (XSTRLEN(start) < 15) { /* 15 is the length of the two
|
||||||
|
constant strings we're about to
|
||||||
|
compare against. */
|
||||||
|
WOLFSSL_MSG("wolfIO_HttpProcessResponse HTTP header too short.");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
if (XSTRNCASECMP(start, "HTTP/1", 6) == 0) {
|
if (XSTRNCASECMP(start, "HTTP/1", 6) == 0) {
|
||||||
start += 9;
|
start += 9;
|
||||||
if (XSTRNCASECMP(start, "200 OK", 6) != 0) {
|
if (XSTRNCASECMP(start, "200 OK", 6) != 0) {
|
||||||
@ -1114,6 +1120,12 @@ int wolfIO_HttpProcessResponse(int sfd, const char** appStrList,
|
|||||||
case phr_http_start:
|
case phr_http_start:
|
||||||
case phr_have_length:
|
case phr_have_length:
|
||||||
case phr_have_type:
|
case phr_have_type:
|
||||||
|
if (XSTRLEN(start) < 13) { /* 13 is the shortest of the following
|
||||||
|
next lines we're checking for. */
|
||||||
|
WOLFSSL_MSG("wolfIO_HttpProcessResponse content type is too short.");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (XSTRNCASECMP(start, "Content-Type:", 13) == 0) {
|
if (XSTRNCASECMP(start, "Content-Type:", 13) == 0) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user