mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 13:56:01 +03:00
Add value checking to @validateByteRange
This commit is contained in:
parent
f260a75c14
commit
4c5bc45dfd
@ -37,6 +37,11 @@ bool ValidateByteRange::getRange(const std::string &rangeRepresentation,
|
|||||||
"' into a number");
|
"' into a number");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if ((start < 0) || (start > 255)) {
|
||||||
|
error->assign("Invalid range start value: " +
|
||||||
|
std::to_string(start));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
table[start >> 3] = (table[start >> 3] | (1 << (start & 0x7)));
|
table[start >> 3] = (table[start >> 3] | (1 << (start & 0x7)));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -60,11 +65,6 @@ bool ValidateByteRange::getRange(const std::string &rangeRepresentation,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((start < 0) || (start > 255)) {
|
|
||||||
error->assign("Invalid range start value: " +
|
|
||||||
std::to_string(start));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if ((end < 0) || (end > 255)) {
|
if ((end < 0) || (end > 255)) {
|
||||||
error->assign("Invalid range end value: " + std::to_string(end));
|
error->assign("Invalid range end value: " + std::to_string(end));
|
||||||
return false;
|
return false;
|
||||||
@ -87,21 +87,29 @@ bool ValidateByteRange::getRange(const std::string &rangeRepresentation,
|
|||||||
bool ValidateByteRange::init(const std::string &file,
|
bool ValidateByteRange::init(const std::string &file,
|
||||||
std::string *error) {
|
std::string *error) {
|
||||||
size_t pos = m_param.find_first_of(",");
|
size_t pos = m_param.find_first_of(",");
|
||||||
|
bool rc;
|
||||||
|
|
||||||
if (pos == std::string::npos) {
|
if (pos == std::string::npos) {
|
||||||
getRange(m_param, error);
|
rc = getRange(m_param, error);
|
||||||
} else {
|
} else {
|
||||||
getRange(std::string(m_param, 0, pos), error);
|
rc = getRange(std::string(m_param, 0, pos), error);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rc == false) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (pos != std::string::npos) {
|
while (pos != std::string::npos) {
|
||||||
size_t next_pos = m_param.find_first_of(",", pos + 1);
|
size_t next_pos = m_param.find_first_of(",", pos + 1);
|
||||||
|
|
||||||
if (next_pos == std::string::npos) {
|
if (next_pos == std::string::npos) {
|
||||||
getRange(std::string(m_param, pos + 1, m_param.length() -
|
rc = getRange(std::string(m_param, pos + 1, m_param.length() -
|
||||||
(pos + 1)), error);
|
(pos + 1)), error);
|
||||||
} else {
|
} else {
|
||||||
getRange(std::string(m_param, pos + 1, next_pos - (pos + 1)), error);
|
rc = getRange(std::string(m_param, pos + 1, next_pos - (pos + 1)), error);
|
||||||
|
}
|
||||||
|
if (rc == false) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
pos = next_pos;
|
pos = next_pos;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user