From: Christian Brauner Date: Wed, 18 Oct 2017 08:34:23 +0000 (+0200) Subject: confile: use correct check on char array X-Git-Tag: lxc-2.0.9~3^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=779b2d1685ecef4ddf29cff9eb11e43c476fd90d;p=thirdparty%2Flxc.git confile: use correct check on char array Signed-off-by: Christian Brauner --- diff --git a/src/lxc/confile.c b/src/lxc/confile.c index 4adfeccc4..1a5f94cc6 100644 --- a/src/lxc/confile.c +++ b/src/lxc/confile.c @@ -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); } diff --git a/src/lxc/confile_utils.c b/src/lxc/confile_utils.c index a7d761e2e..2156b759f 100644 --- a/src/lxc/confile_utils.c +++ b/src/lxc/confile_utils.c @@ -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);