]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
coverity: #1425888
authorChristian Brauner <christian.brauner@ubuntu.com>
Thu, 7 Dec 2017 14:24:28 +0000 (15:24 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Sun, 17 Dec 2017 15:26:59 +0000 (16:26 +0100)
check return value of getifaddrs()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/network.c

index 28d0d8756bc21357b27c19bd530534811c50fa6c..4d17163317fab03f0f816367c06ccb7a50f69931 100644 (file)
@@ -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");