summaryrefslogtreecommitdiffstats
path: root/ext/yahttp
diff options
context:
space:
mode:
Diffstat (limited to 'ext/yahttp')
-rw-r--r--ext/yahttp/yahttp/utility.hpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/ext/yahttp/yahttp/utility.hpp b/ext/yahttp/yahttp/utility.hpp
index 1d5e41e..47457e3 100644
--- a/ext/yahttp/yahttp/utility.hpp
+++ b/ext/yahttp/yahttp/utility.hpp
@@ -1,4 +1,13 @@
#pragma once
+
+#ifndef YAHTTP_MAX_REQUEST_LINE_SIZE
+#define YAHTTP_MAX_REQUEST_LINE_SIZE 8192
+#endif
+
+#ifndef YAHTTP_MAX_REQUEST_FIELDS
+#define YAHTTP_MAX_REQUEST_FIELDS 100
+#endif
+
namespace YaHTTP {
static const char *MONTHS[] = {0,"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec",0}; //<! List of months
static const char *DAYS[] = {"Sun","Mon","Tue","Wed","Thu","Fri","Sat",0}; //<! List of days
@@ -364,7 +373,10 @@ namespace YaHTTP {
}
}; //<! static HTTP codes to text mappings
- static strstr_map_t parseUrlParameters(std::string parameters) {
+ static strstr_map_t parseUrlParameters(const std::string& parameters) {
+ if (parameters.size() > YAHTTP_MAX_REQUEST_LINE_SIZE) {
+ return {};
+ }
std::string::size_type pos = 0;
strstr_map_t parameter_map;
while (pos != std::string::npos) {
@@ -390,13 +402,14 @@ namespace YaHTTP {
// no parameters at all
break;
}
- key = decodeURL(key);
- value = decodeURL(value);
- parameter_map[key] = std::move(value);
+ parameter_map[decodeURL(key)] = decodeURL(value);
if (nextpos == std::string::npos) {
// no more parameters left
break;
}
+ if (parameter_map.size() >= YAHTTP_MAX_REQUEST_FIELDS) {
+ break;
+ }
pos = nextpos+1;
}