]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
confile: error out if a network configuration key has no subkey
authorFelix Abecassis <fabecassis@nvidia.com>
Wed, 29 Nov 2017 04:27:44 +0000 (20:27 -0800)
committerChristian Brauner <christian.brauner@ubuntu.com>
Fri, 15 Dec 2017 11:42:30 +0000 (12:42 +0100)
This prevent an infinite recursion in the case of "lxc.net.0. = a"

Signed-off-by: Felix Abecassis <fabecassis@nvidia.com>
src/lxc/confile.c
src/lxc/confile_legacy.c
src/tests/parse_config_file.c

index af102beb1810b33954fe2003bbea1d2beb47b278..d5c3c3be1adc1ba2ede2d13c4060e9e428033861 100644 (file)
@@ -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';
index 209ae71f38a1f7d5d9cb2393c9e7e96c845de9ee..eb956dd40944bf53a0e5625a25ca47743544033b 100644 (file)
@@ -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) {
index 7479793ac01cfe3583cd4c25e923483d78f37ddc..c679acc28ed8bf81589459b77b75351d2be6b4f8 100644 (file)
@@ -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;