From: Christian Brauner Date: Thu, 7 Dec 2017 14:24:28 +0000 (+0100) Subject: coverity: #1425888 X-Git-Tag: lxc-2.0.10~495 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b8e44b0912099948dbd69bf7e9df8111903c3bc4;p=thirdparty%2Flxc.git coverity: #1425888 check return value of getifaddrs() Signed-off-by: Christian Brauner --- diff --git a/src/lxc/network.c b/src/lxc/network.c index 28d0d8756..4d1716331 100644 --- a/src/lxc/network.c +++ b/src/lxc/network.c @@ -1889,6 +1889,7 @@ static const char padchar[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; char *lxc_mkifname(char *template) { + int ret; unsigned int seed; FILE *urandom; struct ifaddrs *ifa, *ifaddr; @@ -1900,7 +1901,11 @@ char *lxc_mkifname(char *template) return NULL; /* Get all the network interfaces. */ - getifaddrs(&ifaddr); + ret = getifaddrs(&ifaddr); + if (ret < 0) { + ERROR("%s - Failed to get network interfaces", strerror(errno)); + return NULL; + } /* Initialize the random number generator. */ urandom = fopen("/dev/urandom", "r");