Unverified Commit 0a7f6089 by Felix Abecassis Committed by Christian Brauner

confile: error out if a network configuration key has no subkey

This prevent an infinite recursion in the case of "lxc.net.0. = a" Signed-off-by: 's avatarFelix Abecassis <fabecassis@nvidia.com>
parent 46efc088
......@@ -3628,6 +3628,10 @@ static struct lxc_config_t *get_network_config_ops(const char *key,
/* lxc.net.<idx>.<subkey> */
if (idx_end) {
*idx_end = '.';
if (strlen(idx_end + 1) == 0) {
ERROR("No subkey in network configuration key \"%s\"", key);
goto on_error;
}
memmove(copy + 8, idx_end + 1, strlen(idx_end + 1));
copy[strlen(key) - numstrlen + 1] = '\0';
......
......@@ -90,6 +90,10 @@ int set_config_network_legacy_nic(const char *key, const char *value,
if (!p)
goto out;
if (strlen(p + 1) == 0) {
ERROR("No subkey in network configuration key \"%s\"", key);
goto out;
}
strcpy(copy + 12, p + 1);
config = lxc_get_config(copy);
if (!config) {
......
......@@ -166,6 +166,16 @@ static int set_invalid_netdev(struct lxc_container *c) {
return -1;
}
if (c->set_config_item(c, "lxc.net.0.", "veth")) {
lxc_error("%s\n", "lxc.net.0. should be invalid");
return -1;
}
if (c->set_config_item(c, "lxc.network.0.", "veth")) {
lxc_error("%s\n", "lxc.network.0. should be invalid");
return -1;
}
c->clear_config(c);
c->lxc_conf = NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment