mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-13 13:26:01 +03:00
Change SecRequestBody(NoFiles)Limit parsing method
This commit is contained in:
parent
cf24aeaead
commit
42b6101bda
File diff suppressed because it is too large
Load Diff
@ -1609,12 +1609,20 @@ expression:
|
||||
| CONFIG_DIR_REQ_BODY_LIMIT
|
||||
{
|
||||
driver.m_requestBodyLimit.m_set = true;
|
||||
driver.m_requestBodyLimit.m_value = atoi($1.c_str());
|
||||
if (modsecurity::utils::string::parse_unsigned_int($1, &driver.m_requestBodyLimit.m_value) != 1) {
|
||||
std::stringstream ss;
|
||||
ss << "Failed to parse SecRequestBodyLimit value as an unsigned integer.";
|
||||
driver.error(@0, ss.str());
|
||||
}
|
||||
}
|
||||
| CONFIG_DIR_REQ_BODY_NO_FILES_LIMIT
|
||||
{
|
||||
driver.m_requestBodyNoFilesLimit.m_set = true;
|
||||
driver.m_requestBodyNoFilesLimit.m_value = atoi($1.c_str());
|
||||
if (modsecurity::utils::string::parse_unsigned_int($1, &driver.m_requestBodyNoFilesLimit.m_value) != 1) {
|
||||
std::stringstream ss;
|
||||
ss << "Failed to parse SecRequestBodyNoFilesLimit value as an unsigned integer.";
|
||||
driver.error(@0, ss.str());
|
||||
}
|
||||
}
|
||||
| CONFIG_DIR_REQ_BODY_IN_MEMORY_LIMIT
|
||||
{
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <time.h>
|
||||
#include <climits>
|
||||
|
||||
#ifdef WIN32
|
||||
#include "src/compat/msvc.h"
|
||||
@ -276,6 +277,30 @@ inline std::string toupper(std::string str) { // cppcheck-suppress passedByValue
|
||||
return toCaseHelper(str, ::toupper);
|
||||
}
|
||||
|
||||
inline int parse_unsigned_int(std::string a, unsigned int *res) {
|
||||
char *endptr = NULL;
|
||||
errno = 0;
|
||||
|
||||
unsigned long val = strtoul(a.c_str(), &endptr, 10);
|
||||
|
||||
if (a.c_str() == endptr) {
|
||||
// no number
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (*endptr != '\0') {
|
||||
// broken conversion
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (errno == ERANGE || val > UINT_MAX) {
|
||||
// unsigned int overflow
|
||||
return 0;
|
||||
}
|
||||
|
||||
*res = static_cast<unsigned int>(val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
} // namespace modsecurity::utils::string
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user