mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-08 21:17:47 +03:00
network: refuse empty or numeric route table names
This commit is contained in:
parent
283f7c9872
commit
d2d602f4b4
@ -360,9 +360,19 @@ int config_parse_route_table_names(
|
|||||||
|
|
||||||
*num++ = '\0';
|
*num++ = '\0';
|
||||||
|
|
||||||
|
if (isempty(name)) {
|
||||||
|
log_syntax(unit, LOG_WARNING, filename, line, 0,
|
||||||
|
"Route table name cannot be empty. Ignoring assignment: %s:%s", name, num);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (in_charset(name, DIGITS)) {
|
||||||
|
log_syntax(unit, LOG_WARNING, filename, line, 0,
|
||||||
|
"Route table name cannot be numeric. Ignoring assignment: %s:%s", name, num);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (STR_IN_SET(name, "default", "main", "local")) {
|
if (STR_IN_SET(name, "default", "main", "local")) {
|
||||||
log_syntax(unit, LOG_WARNING, filename, line, 0,
|
log_syntax(unit, LOG_WARNING, filename, line, 0,
|
||||||
"Route table name %s already predefined. Ignoring assignment: %s:%s", name, name, num);
|
"Route table name %s is already predefined. Ignoring assignment: %s:%s", name, name, num);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,6 +146,12 @@ static void test_route_tables(Manager *manager) {
|
|||||||
assert_se(!manager->route_table_names_by_number);
|
assert_se(!manager->route_table_names_by_number);
|
||||||
assert_se(!manager->route_table_numbers_by_name);
|
assert_se(!manager->route_table_numbers_by_name);
|
||||||
|
|
||||||
|
/* Invalid pairs */
|
||||||
|
assert_se(config_parse_route_table_names("manager", "filename", 1, "section", 1, "RouteTable", 0, "main:123 default:333 local:999", manager, manager) >= 0);
|
||||||
|
assert_se(config_parse_route_table_names("manager", "filename", 1, "section", 1, "RouteTable", 0, "1234:321 :567 hoge:foo aaa:-888", manager, manager) >= 0);
|
||||||
|
assert_se(!manager->route_table_names_by_number);
|
||||||
|
assert_se(!manager->route_table_numbers_by_name);
|
||||||
|
|
||||||
test_route_tables_one(manager, "default", 253);
|
test_route_tables_one(manager, "default", 253);
|
||||||
test_route_tables_one(manager, "main", 254);
|
test_route_tables_one(manager, "main", 254);
|
||||||
test_route_tables_one(manager, "local", 255);
|
test_route_tables_one(manager, "local", 255);
|
||||||
|
Loading…
Reference in New Issue
Block a user