]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
cast NULL pointers passed to execl*() 826/head
authorChristian Brauner <christian.brauner@mailbox.org>
Fri, 19 Feb 2016 11:44:40 +0000 (12:44 +0100)
committerChristian Brauner <christian.brauner@mailbox.org>
Fri, 19 Feb 2016 11:44:40 +0000 (12:44 +0100)
NULL pointers passed to execl*() functions must be cast to (char *)NULL since
they are variadic functions.

Signed-off-by: Christian Brauner <christian.brauner@mailbox.org>
src/lxc/attach.c
src/lxc/bdev/bdev.c
src/lxc/bdev/lxclvm.c
src/lxc/bdev/lxcnbd.c
src/lxc/bdev/lxcrbd.c
src/lxc/bdev/lxczfs.c
src/lxc/network.c

index 68f68ffbccca509f7d3a541ff17e43e220d14c03..da5a5572c36c6b66c5493fe86554d1fe40560cc0 100644 (file)
@@ -1252,12 +1252,12 @@ int lxc_attach_run_shell(void* payload)
                user_shell = passwd->pw_shell;
 
        if (user_shell)
-               execlp(user_shell, user_shell, NULL);
+               execlp(user_shell, user_shell, (char *)NULL);
 
        /* executed if either no passwd entry or execvp fails,
         * we will fall back on /bin/sh as a default shell
         */
-       execlp("/bin/sh", "/bin/sh", NULL);
+       execlp("/bin/sh", "/bin/sh", (char *)NULL);
        SYSERROR("failed to exec shell");
        return -1;
 }
index 3c68a43b579c6360ac5f28f01c1f0754fc615a83..090b68579f80fd20d0de260f6a9282b889edd319 100644 (file)
@@ -721,7 +721,7 @@ int do_mkfs(const char *path, const char *fstype)
        // us about whether to proceed.
        if (null_stdfds() < 0)
                exit(1);
-       execlp("mkfs", "mkfs", "-t", fstype, path, NULL);
+       execlp("mkfs", "mkfs", "-t", fstype, path, (char *)NULL);
        exit(1);
 }
 
index 6f8587941bd9de95f49023900cbbb1fbb9e0a27b..3d41b10fb4170bf2ca2bd0bb09796795d6c71984 100644 (file)
@@ -356,7 +356,7 @@ int lvm_destroy(struct bdev *orig)
        if ((pid = fork()) < 0)
                return -1;
        if (!pid) {
-               execlp("lvremove", "lvremove", "-f", orig->src, NULL);
+               execlp("lvremove", "lvremove", "-f", orig->src, (char *)NULL);
                exit(EXIT_FAILURE);
        }
        return wait_for_pid(pid);
index 2f68a00cf22f46cb8e02e9c1a5fc00f40491bc03..8a320d2097109d9cbb9843348e09814c1b3067a0 100644 (file)
@@ -228,7 +228,7 @@ static int do_attach_nbd(void *d)
        if (sigprocmask(SIG_UNBLOCK, &mask, NULL) == -1)
                WARN("Warning: unblocking signals for nbd watcher");
 
-       execlp("qemu-nbd", "qemu-nbd", "-c", nbd, path, NULL);
+       execlp("qemu-nbd", "qemu-nbd", "-c", nbd, path, (char *)NULL);
        SYSERROR("Error executing qemu-nbd");
        exit(1);
 }
@@ -273,7 +273,7 @@ static void nbd_detach(const char *path)
                        ERROR("nbd disconnect returned an error");
                return;
        }
-       execlp("qemu-nbd", "qemu-nbd", "-d", path, NULL);
+       execlp("qemu-nbd", "qemu-nbd", "-d", path, (char *)NULL);
        SYSERROR("Error executing qemu-nbd");
        exit(1);
 }
index 113d2fcb99f0dd06ab294be0134c4cc8e64d30dd..8e3a452b7d7490f6e57a01eefa47220ec0ca8d76 100644 (file)
@@ -85,7 +85,7 @@ int rbd_create(struct bdev *bdev, const char *dest, const char *n,
        if ((pid = fork()) < 0)
                return -1;
        if (!pid) {
-               execlp("rbd", "rbd", "create" , "--pool", rbdpool, rbdname, "--size", sz, NULL);
+               execlp("rbd", "rbd", "create" , "--pool", rbdpool, rbdname, "--size", sz, (char *)NULL);
                exit(1);
        }
        if (wait_for_pid(pid) < 0)
@@ -94,7 +94,7 @@ int rbd_create(struct bdev *bdev, const char *dest, const char *n,
        if ((pid = fork()) < 0)
                return -1;
        if (!pid) {
-               execlp("rbd", "rbd", "map", "--pool", rbdpool, rbdname, NULL);
+               execlp("rbd", "rbd", "map", "--pool", rbdpool, rbdname, (char *)NULL);
                exit(1);
        }
        if (wait_for_pid(pid) < 0)
@@ -129,7 +129,7 @@ int rbd_destroy(struct bdev *orig)
                if ((pid = fork()) < 0)
                        return -1;
                if (!pid) {
-                       execlp("rbd", "rbd", "unmap" , orig->src, NULL);
+                       execlp("rbd", "rbd", "unmap" , orig->src, (char *)NULL);
                        exit(1);
                }
                if (wait_for_pid(pid) < 0)
@@ -141,7 +141,7 @@ int rbd_destroy(struct bdev *orig)
        if (!pid) {
                rbdfullname = alloca(strlen(orig->src) - 8);
                strcpy( rbdfullname, &orig->src[9] );
-               execlp("rbd", "rbd", "rm" , rbdfullname, NULL);
+               execlp("rbd", "rbd", "rm" , rbdfullname, (char *)NULL);
                exit(1);
        }
        return wait_for_pid(pid);
index def50839aa8cb4639f365d37150936f581f8e949..dd1005bb2cc108162699e72b2fc8c83d422647c5 100644 (file)
@@ -150,7 +150,7 @@ int zfs_clone(const char *opath, const char *npath, const char *oname,
                        ret = snprintf(dev, MAXPATHLEN, "%s/%s", zfsroot, nname);
                        if (ret < 0  || ret >= MAXPATHLEN)
                                exit(EXIT_FAILURE);
-                       execlp("zfs", "zfs", "create", option, dev, NULL);
+                       execlp("zfs", "zfs", "create", option, dev, (char *)NULL);
                        exit(EXIT_FAILURE);
                }
                return wait_for_pid(pid);
@@ -170,7 +170,7 @@ int zfs_clone(const char *opath, const char *npath, const char *oname,
                if ((pid = fork()) < 0)
                        return -1;
                if (!pid) {
-                       execlp("zfs", "zfs", "destroy", path1, NULL);
+                       execlp("zfs", "zfs", "destroy", path1, (char *)NULL);
                        exit(EXIT_FAILURE);
                }
                // it probably doesn't exist so destroy probably will fail.
@@ -180,7 +180,7 @@ int zfs_clone(const char *opath, const char *npath, const char *oname,
                if ((pid = fork()) < 0)
                        return -1;
                if (!pid) {
-                       execlp("zfs", "zfs", "snapshot", path1, NULL);
+                       execlp("zfs", "zfs", "snapshot", path1, (char *)NULL);
                        exit(EXIT_FAILURE);
                }
                if (wait_for_pid(pid) < 0)
@@ -190,7 +190,7 @@ int zfs_clone(const char *opath, const char *npath, const char *oname,
                if ((pid = fork()) < 0)
                        return -1;
                if (!pid) {
-                       execlp("zfs", "zfs", "clone", option, path1, path2, NULL);
+                       execlp("zfs", "zfs", "clone", option, path1, path2, (char *)NULL);
                        exit(EXIT_FAILURE);
                }
                return wait_for_pid(pid);
@@ -252,7 +252,7 @@ int zfs_destroy(struct bdev *orig)
                return -1;
        *p = '\0';
 
-       execlp("zfs", "zfs", "destroy", output, NULL);
+       execlp("zfs", "zfs", "destroy", output, (char *)NULL);
        exit(EXIT_FAILURE);
 }
 
@@ -291,6 +291,6 @@ int zfs_create(struct bdev *bdev, const char *dest, const char *n,
        if (ret < 0  || ret >= MAXPATHLEN)
                exit(EXIT_FAILURE);
 
-       execlp("zfs", "zfs", "create", option, dev, NULL);
+       execlp("zfs", "zfs", "create", option, dev, (char *)NULL);
        exit(EXIT_FAILURE);
 }
index 49633abcfc5a5c516e2640eae765611c1865c79a..31c82bbbbe4ca2d7dfe958e85a40667c3ff95f71 100644 (file)
@@ -162,7 +162,7 @@ static char * is_wlan(const char *ifname)
        fseek(f, 0, SEEK_SET);
        physname = malloc(physlen+1);
        if (!physname) {
-               fclose(f);      
+               fclose(f);
                goto bad;
        }
        memset(physname, 0, physlen+1);
@@ -221,7 +221,7 @@ lxc_netdev_move_wlan(char *physname, const char *ifname, pid_t pid, const char*
        if (fpid == 0) {
                char pidstr[30];
                sprintf(pidstr, "%d", pid);
-               if (execlp("iw", "iw", "phy", physname, "set", "netns", pidstr, NULL))
+               if (execlp("iw", "iw", "phy", physname, "set", "netns", pidstr, (char *)NULL))
                        exit(1);
                exit(0); // notreached
        }
@@ -1056,13 +1056,13 @@ static int ip_addr_add(int family, int ifindex,
        nlmsg->nlmsghdr->nlmsg_type = RTM_NEWADDR;
 
        ifa = nlmsg_reserve(nlmsg, sizeof(struct ifaddrmsg));
-       if (!ifa) 
+       if (!ifa)
                goto out;
        ifa->ifa_prefixlen = prefix;
        ifa->ifa_index = ifindex;
        ifa->ifa_family = family;
        ifa->ifa_scope = 0;
-       
+
        err = -EINVAL;
        if (nla_put_buffer(nlmsg, IFA_LOCAL, addr, addrlen))
                goto out;
@@ -1339,23 +1339,23 @@ static int ip_route_dest_add(int family, int ifindex, void *dest)
        struct rtmsg *rt;
        int addrlen;
        int err;
-       
+
        addrlen = family == AF_INET ? sizeof(struct in_addr) :
                sizeof(struct in6_addr);
-       
+
        err = netlink_open(&nlh, NETLINK_ROUTE);
        if (err)
                return err;
-       
+
        err = -ENOMEM;
        nlmsg = nlmsg_alloc(NLMSG_GOOD_SIZE);
        if (!nlmsg)
                goto out;
-       
+
        answer = nlmsg_alloc_reserve(NLMSG_GOOD_SIZE);
        if (!answer)
                goto out;
-       
+
        nlmsg->nlmsghdr->nlmsg_flags =
                NLM_F_ACK|NLM_F_REQUEST|NLM_F_CREATE|NLM_F_EXCL;
        nlmsg->nlmsghdr->nlmsg_type = RTM_NEWROUTE;
@@ -1369,7 +1369,7 @@ static int ip_route_dest_add(int family, int ifindex, void *dest)
        rt->rtm_protocol = RTPROT_BOOT;
        rt->rtm_type = RTN_UNICAST;
        rt->rtm_dst_len = addrlen*8;
-       
+
        err = -EINVAL;
        if (nla_put_buffer(nlmsg, RTA_DST, dest, addrlen))
                goto out;
@@ -1414,7 +1414,7 @@ static void ovs_cleanup_nic(const char *lxcpath, const char *name, const char *b
                return;
        if (lxc_wait(name, "STOPPED", -1, lxcpath) < 0)
                return;
-       execlp("ovs-vsctl", "ovs-vsctl", "del-port", bridge, nic, NULL);
+       execlp("ovs-vsctl", "ovs-vsctl", "del-port", bridge, nic, (char *)NULL);
        exit(1); /* not reached */
 }
 
@@ -1445,7 +1445,7 @@ static int attach_to_ovs_bridge(const char *lxcpath, const char *name, const cha
                exit(0);
        }
 
-       if (execlp("ovs-vsctl", "ovs-vsctl", "add-port", bridge, nic, NULL))
+       if (execlp("ovs-vsctl", "ovs-vsctl", "add-port", bridge, nic, (char *)NULL))
                exit(1);
        // not reached
        exit(1);