Skip to content

Commit 4d4b879

Browse files
committedOct 22, 2012
pud: fix socket error
Coverity: CID 739662 (#2 of 2): Argument cannot be negative (NEGATIVE_RETURNS) At (9): "fd" is passed to a parameter that cannot be negative. Signed-off-by: Ferry Huberts <[email protected]>
1 parent afd17ee commit 4d4b879

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed
 

‎lib/pud/src/netTools.c

+6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
/* System includes */
99
#include <sys/ioctl.h>
10+
#include <errno.h>
11+
#include <string.h>
1012

1113
/**
1214
Get the hardware address (MAC) of an interface
@@ -33,6 +35,10 @@ unsigned char * getHardwareAddress(const char * ifName, int family,
3335
assert(ifr != NULL);
3436

3537
fd = socket(family, SOCK_DGRAM, 0);
38+
if (fd < 0) {
39+
pudError(true, "%s@%u: socket error: %s", __FILE__, __LINE__, strerror(errno));
40+
return NULL;
41+
}
3642

3743
ifr->ifr_addr.sa_family = family;
3844
memset(ifr->ifr_name, 0, sizeof(ifr->ifr_name));

0 commit comments

Comments
 (0)