mirror of
https://github.com/yhirose/cpp-httplib
synced 2024-11-21 14:29:10 -07:00
Fix "Issue 42689 in oss-fuzz: cpp-httplib:server_fuzzer: Timeout in server_fuzzer"
This commit is contained in:
parent
99ac17b90a
commit
63f72caf30
1 changed files with 8 additions and 1 deletions
|
@ -60,6 +60,10 @@
|
|||
#define CPPHTTPLIB_REQUEST_URI_MAX_LENGTH 8192
|
||||
#endif
|
||||
|
||||
#ifndef CPPHTTPLIB_HEADER_MAX_LENGTH
|
||||
#define CPPHTTPLIB_HEADER_MAX_LENGTH 8192
|
||||
#endif
|
||||
|
||||
#ifndef CPPHTTPLIB_REDIRECT_MAX_COUNT
|
||||
#define CPPHTTPLIB_REDIRECT_MAX_COUNT 20
|
||||
#endif
|
||||
|
@ -3178,6 +3182,8 @@ inline bool read_headers(Stream &strm, Headers &headers) {
|
|||
continue; // Skip invalid line.
|
||||
}
|
||||
|
||||
if (line_reader.size() > CPPHTTPLIB_HEADER_MAX_LENGTH) { return false; }
|
||||
|
||||
// Exclude CRLF
|
||||
auto end = line_reader.ptr() + line_reader.size() - 2;
|
||||
|
||||
|
@ -3703,6 +3709,7 @@ public:
|
|||
}
|
||||
case 2: { // Headers
|
||||
auto pos = buf_find(crlf_);
|
||||
if (pos > CPPHTTPLIB_HEADER_MAX_LENGTH) { return false; }
|
||||
while (pos < buf_size()) {
|
||||
// Empty line
|
||||
if (pos == 0) {
|
||||
|
@ -3866,7 +3873,7 @@ private:
|
|||
|
||||
void buf_append(const char *data, size_t n) {
|
||||
auto remaining_size = buf_size();
|
||||
if (remaining_size > 0) {
|
||||
if (remaining_size > 0 && buf_spos_ > 0) {
|
||||
for (size_t i = 0; i < remaining_size; i++) {
|
||||
buf_[i] = buf_[buf_spos_ + i];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue