Skip to content

Commit

Permalink
coverity: #1425888
Browse files Browse the repository at this point in the history
check return value of getifaddrs()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
  • Loading branch information
Christian Brauner committed Dec 17, 2017
1 parent fc87280 commit b8e44b0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/lxc/network.c
Expand Up @@ -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;
Expand All @@ -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");
Expand Down

0 comments on commit b8e44b0

Please sign in to comment.