]> 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)
committerFelix Abecassis <fabecassis@nvidia.com>
Wed, 29 Nov 2017 04:41:51 +0000 (20:41 -0800)
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 c6a0aeef988a2799232865ef7e8caf629249164e..a2e5ba7c1239cf3234972d9a6471ac0d02f6d53d 100644 (file)
@@ -3801,6 +3801,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;