1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-25 06:03:36 +03:00

B #5458: Check SG port range in 0-65535 (#1364)

(cherry picked from commit af2de3f5424fd55d81150d40b174e8f25f4745b6)
This commit is contained in:
Pavel Czerný 2021-07-22 10:26:21 +02:00 committed by Ruben S. Montero
parent d0619d2cb5
commit 3d15223760
No known key found for this signature in database
GPG Key ID: A0CEA6FA880A1D87

View File

@ -342,6 +342,19 @@ bool SecurityGroup::is_valid(const VectorAttribute * rule, string& error) const
error = "Invalid RANGE specification.";
return false;
}
// Check all port numbers are between 0-65535
const char *big_port_pattern = "([1-9][[:digit:]]{5,}|"
"[7-9][[:digit:]]{4,}|"
"6[6-9][[:digit:]]{3,}|"
"65[6-9][[:digit:]]{2,}|"
"655[4-9][[:digit:]]|"
"6553[6-9])";
if (one_util::regex_match(big_port_pattern, value.c_str()) == 0)
{
error = "RANGE out of bounds 0-65536.";
return false;
}
}
value = rule->vector_value("ICMP_TYPE");