|
@@ -8762,13 +8762,18 @@ parse_http_request(char *buf, int len, struct mg_request_info *ri)
|
|
|
|
|
|
/* RFC says that all initial whitespaces should be ingored */
|
|
|
/* This included all leading \r and \n (isspace) */
|
|
|
- /* See table: http://www.cplusplus.com/reference/cctype/ */
|
|
|
+ /* See table: http://www.cplusplus.com/reference/cctype/ */
|
|
|
while ((len > 0) && isspace(*(unsigned char *)buf)) {
|
|
|
buf++;
|
|
|
len--;
|
|
|
init_skip++;
|
|
|
}
|
|
|
|
|
|
+ if (len == 0) {
|
|
|
+ /* Incomplete request */
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
/* Control characters are not allowed, including zero */
|
|
|
if (iscntrl(*(unsigned char *)buf)) {
|
|
|
return -1;
|
|
@@ -8844,13 +8849,18 @@ parse_http_response(char *buf, int len, struct mg_response_info *ri)
|
|
|
|
|
|
/* RFC says that all initial whitespaces should be ingored */
|
|
|
/* This included all leading \r and \n (isspace) */
|
|
|
- /* See table: http://www.cplusplus.com/reference/cctype/ */
|
|
|
+ /* See table: http://www.cplusplus.com/reference/cctype/ */
|
|
|
while ((len > 0) && isspace(*(unsigned char *)buf)) {
|
|
|
buf++;
|
|
|
len--;
|
|
|
init_skip++;
|
|
|
}
|
|
|
|
|
|
+ if (len == 0) {
|
|
|
+ /* Incomplete request */
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
/* Control characters are not allowed, including zero */
|
|
|
if (iscntrl(*(unsigned char *)buf)) {
|
|
|
return -1;
|