Commit d05d2975e87da8799ebda99876ce576529fdacd9
1 parent
80d5cf8b
Fix HTTP parsing invalid data
Found by fuzzing.
Showing
1 changed file
with
6 additions
and
0 deletions
utils.cpp
| @@ -280,6 +280,12 @@ bool parseHttpHeader(CirBuf &buf, std::string &websocket_key, int &websocket_ver | @@ -280,6 +280,12 @@ bool parseHttpHeader(CirBuf &buf, std::string &websocket_key, int &websocket_ver | ||
| 280 | } | 280 | } |
| 281 | 281 | ||
| 282 | std::list<std::string> fields = split(line, ':', 1); | 282 | std::list<std::string> fields = split(line, ':', 1); |
| 283 | + | ||
| 284 | + if (fields.size() != 2) | ||
| 285 | + { | ||
| 286 | + throw BadHttpRequest("This does not look like a HTTP request."); | ||
| 287 | + } | ||
| 288 | + | ||
| 283 | const std::vector<std::string> fields2(fields.begin(), fields.end()); | 289 | const std::vector<std::string> fields2(fields.begin(), fields.end()); |
| 284 | std::string name = str_tolower(fields2[0]); | 290 | std::string name = str_tolower(fields2[0]); |
| 285 | trim(name); | 291 | trim(name); |