Fix "Issue 42689 in oss-fuzz: cpp-httplib:server_fuzzer: Timeout in server_fuzzer"
This commit is contained in:
parent
99ac17b90a
commit
63f72caf30
@ -60,6 +60,10 @@
|
|||||||
#define CPPHTTPLIB_REQUEST_URI_MAX_LENGTH 8192
|
#define CPPHTTPLIB_REQUEST_URI_MAX_LENGTH 8192
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef CPPHTTPLIB_HEADER_MAX_LENGTH
|
||||||
|
#define CPPHTTPLIB_HEADER_MAX_LENGTH 8192
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef CPPHTTPLIB_REDIRECT_MAX_COUNT
|
#ifndef CPPHTTPLIB_REDIRECT_MAX_COUNT
|
||||||
#define CPPHTTPLIB_REDIRECT_MAX_COUNT 20
|
#define CPPHTTPLIB_REDIRECT_MAX_COUNT 20
|
||||||
#endif
|
#endif
|
||||||
@ -3178,6 +3182,8 @@ inline bool read_headers(Stream &strm, Headers &headers) {
|
|||||||
continue; // Skip invalid line.
|
continue; // Skip invalid line.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (line_reader.size() > CPPHTTPLIB_HEADER_MAX_LENGTH) { return false; }
|
||||||
|
|
||||||
// Exclude CRLF
|
// Exclude CRLF
|
||||||
auto end = line_reader.ptr() + line_reader.size() - 2;
|
auto end = line_reader.ptr() + line_reader.size() - 2;
|
||||||
|
|
||||||
@ -3703,6 +3709,7 @@ public:
|
|||||||
}
|
}
|
||||||
case 2: { // Headers
|
case 2: { // Headers
|
||||||
auto pos = buf_find(crlf_);
|
auto pos = buf_find(crlf_);
|
||||||
|
if (pos > CPPHTTPLIB_HEADER_MAX_LENGTH) { return false; }
|
||||||
while (pos < buf_size()) {
|
while (pos < buf_size()) {
|
||||||
// Empty line
|
// Empty line
|
||||||
if (pos == 0) {
|
if (pos == 0) {
|
||||||
@ -3866,7 +3873,7 @@ private:
|
|||||||
|
|
||||||
void buf_append(const char *data, size_t n) {
|
void buf_append(const char *data, size_t n) {
|
||||||
auto remaining_size = buf_size();
|
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++) {
|
for (size_t i = 0; i < remaining_size; i++) {
|
||||||
buf_[i] = buf_[buf_spos_ + i];
|
buf_[i] = buf_[buf_spos_ + i];
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user