]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
confile: use correct check on char array 1863/head
authorChristian Brauner <christian.brauner@ubuntu.com>
Wed, 18 Oct 2017 08:34:23 +0000 (10:34 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Wed, 18 Oct 2017 09:24:53 +0000 (11:24 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/confile.c
src/lxc/confile_utils.c

index 4adfeccc46ece905ba79dce7d05ab35e8ee67bb5..1a5f94cc648809997cf015cc5aa93c527678b6ed 100644 (file)
@@ -3357,12 +3357,12 @@ static int get_config_network_item(const char *key, char *retv, int inlen,
        if (!netdev)
                return -1;
        if (strcmp(p1, "name") == 0) {
-               if (netdev->name)
+               if (netdev->name[0] != '\0')
                        strprint(retv, inlen, "%s", netdev->name);
        } else if (strcmp(p1, "type") == 0) {
                strprint(retv, inlen, "%s", lxc_net_type_to_str(netdev->type));
        } else if (strcmp(p1, "link") == 0) {
-               if (netdev->link)
+               if (netdev->link[0] != '\0')
                        strprint(retv, inlen, "%s", netdev->link);
        } else if (strcmp(p1, "flags") == 0) {
                if (netdev->flags & IFF_UP)
@@ -3404,7 +3404,7 @@ static int get_config_network_item(const char *key, char *retv, int inlen,
        } else if (strcmp(p1, "veth.pair") == 0) {
                if (netdev->type == LXC_NET_VETH) {
                        strprint(retv, inlen, "%s",
-                                netdev->priv.veth_attr.pair
+                                netdev->priv.veth_attr.pair[0] != '\0'
                                     ? netdev->priv.veth_attr.pair
                                     : netdev->priv.veth_attr.veth1);
                }
index a7d761e2e7cf5e3b59c2a24e1fbab785656dddfe..2156b759f9ea3656bacea4e28324251fb18795ee 100644 (file)
@@ -256,7 +256,7 @@ void lxc_log_configured_netdevs(const struct lxc_conf *conf)
                switch (netdev->type) {
                case LXC_NET_VETH:
                        TRACE("type: veth");
-                       if (netdev->priv.veth_attr.pair)
+                       if (netdev->priv.veth_attr.pair[0] != '\0')
                                TRACE("veth pair: %s",
                                      netdev->priv.veth_attr.pair);
                        if (netdev->priv.veth_attr.veth1[0] != '\0')
@@ -291,9 +291,9 @@ void lxc_log_configured_netdevs(const struct lxc_conf *conf)
                }
 
                TRACE("flags: %s", netdev->flags == IFF_UP ? "up" : "none");
-               if (netdev->link)
+               if (netdev->link[0] != '\0')
                        TRACE("link: %s", netdev->link);
-               if (netdev->name)
+               if (netdev->name[0] != '\0')
                        TRACE("name: %s", netdev->name);
                if (netdev->hwaddr)
                        TRACE("hwaddr: %s", netdev->hwaddr);