]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
confile: add strdup failure check
authorLiza Tretyakova <elizabet.tretyakova@gmail.com>
Sat, 19 May 2018 13:24:25 +0000 (16:24 +0300)
committerChristian Brauner <christian.brauner@ubuntu.com>
Sun, 22 Jul 2018 13:50:29 +0000 (15:50 +0200)
Signed-off-by: Liza Tretyakova <elizabet.tretyakova@gmail.com>
[christian.brauner@ubuntu.com: coding style]
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/confile.c

index cb595a340fd7786e7f197893c922f1d3f2c3f3a5..091dc67d9b5ab2ee82a02af5ade18c43e731ebbc 100644 (file)
@@ -1689,8 +1689,8 @@ static int set_config_mount_auto(const char *key, const char *value,
                        if (!strcmp(allowed_auto_mounts[i].token, token))
                                break;
 
-                       if (strcmp("shmounts:", allowed_auto_mounts[i].token) == 0
-                                       && strncmp("shmounts:", token, sizeof("shmounts:") - 1) == 0) {
+                       if (strcmp("shmounts:", allowed_auto_mounts[i].token) == 0 &&
+                           strncmp("shmounts:", token, sizeof("shmounts:") - 1) == 0) {
                                is_shmounts = true;
                                break;
                        }
@@ -1705,11 +1705,21 @@ static int set_config_mount_auto(const char *key, const char *value,
                lxc_conf->auto_mounts |= allowed_auto_mounts[i].flag;
                if (is_shmounts) {
                        lxc_conf->shmount.path_host = strdup(token + (sizeof("shmounts:") - 1));
+                       if (!lxc_conf->shmount.path_host) {
+                               SYSERROR("Failed to copy shmounts host path");
+                               break;
+                       }
+
                        if (strcmp(lxc_conf->shmount.path_host, "") == 0) {
                                ERROR("Invalid shmounts path: empty");
                                break;
                        }
+
                        lxc_conf->shmount.path_cont = strdup("/dev/.lxc-mounts");
+                       if(!lxc_conf->shmount.path_cont) {
+                               SYSERROR("Failed to copy shmounts container path");
+                               break;
+                       }
                }
        }