Skip to content

Commit cba9ef8

Browse files
committed
Issue 49740 in oss-fuzz: cpp-httplib:server_fuzzer: Timeout in server_fuzzer
1 parent 4f8407a commit cba9ef8

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

httplib.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@
7070
#define CPPHTTPLIB_REDIRECT_MAX_COUNT 20
7171
#endif
7272

73+
#ifndef CPPHTTPLIB_MULTIPART_FORM_DATA_FILE_MAX_COUNT
74+
#define CPPHTTPLIB_MULTIPART_FORM_DATA_FILE_MAX_COUNT 1024
75+
#endif
76+
7377
#ifndef CPPHTTPLIB_PAYLOAD_MAX_LENGTH
7478
#define CPPHTTPLIB_PAYLOAD_MAX_LENGTH ((std::numeric_limits<size_t>::max)())
7579
#endif
@@ -5255,6 +5259,7 @@ Server::write_content_with_provider(Stream &strm, const Request &req,
52555259

52565260
inline bool Server::read_content(Stream &strm, Request &req, Response &res) {
52575261
MultipartFormDataMap::iterator cur;
5262+
auto file_count = 0;
52585263
if (read_content_core(
52595264
strm, req, res,
52605265
// Regular
@@ -5265,6 +5270,9 @@ inline bool Server::read_content(Stream &strm, Request &req, Response &res) {
52655270
},
52665271
// Multipart
52675272
[&](const MultipartFormData &file) {
5273+
if (file_count++ == CPPHTTPLIB_MULTIPART_FORM_DATA_FILE_MAX_COUNT) {
5274+
return false;
5275+
}
52685276
cur = req.files.emplace(file.name, file);
52695277
return true;
52705278
},

0 commit comments

Comments
 (0)