File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change 6060#define CPPHTTPLIB_REQUEST_URI_MAX_LENGTH 8192
6161#endif
6262
63+ #ifndef CPPHTTPLIB_HEADER_MAX_LENGTH
64+ #define CPPHTTPLIB_HEADER_MAX_LENGTH 8192
65+ #endif
66+
6367#ifndef CPPHTTPLIB_REDIRECT_MAX_COUNT
6468#define CPPHTTPLIB_REDIRECT_MAX_COUNT 20
6569#endif
@@ -3178,6 +3182,8 @@ inline bool read_headers(Stream &strm, Headers &headers) {
31783182 continue ; // Skip invalid line.
31793183 }
31803184
3185+ if (line_reader.size () > CPPHTTPLIB_HEADER_MAX_LENGTH) { return false ; }
3186+
31813187 // Exclude CRLF
31823188 auto end = line_reader.ptr () + line_reader.size () - 2 ;
31833189
@@ -3703,6 +3709,7 @@ class MultipartFormDataParser {
37033709 }
37043710 case 2 : { // Headers
37053711 auto pos = buf_find (crlf_);
3712+ if (pos > CPPHTTPLIB_HEADER_MAX_LENGTH) { return false ; }
37063713 while (pos < buf_size ()) {
37073714 // Empty line
37083715 if (pos == 0 ) {
@@ -3866,7 +3873,7 @@ class MultipartFormDataParser {
38663873
38673874 void buf_append (const char *data, size_t n) {
38683875 auto remaining_size = buf_size ();
3869- if (remaining_size > 0 ) {
3876+ if (remaining_size > 0 && buf_spos_ > 0 ) {
38703877 for (size_t i = 0 ; i < remaining_size; i++) {
38713878 buf_[i] = buf_[buf_spos_ + i];
38723879 }
You can’t perform that action at this time.
0 commit comments