diff options
author | ngie <ngie@FreeBSD.org> | 2016-05-29 03:42:50 +0000 |
---|---|---|
committer | ngie <ngie@FreeBSD.org> | 2016-05-29 03:42:50 +0000 |
commit | 2fd21198ee670ba90a6e8dc33a5575ae87e23ddb (patch) | |
tree | 350d8e5e4b0f3081e1a41dc1e2287d39fe7fc7fb /usr.sbin/rpcbind/util.c | |
parent | 1f776afa1cbc91a2631273ffc11b3d2b05a20628 (diff) | |
download | FreeBSD-src-2fd21198ee670ba90a6e8dc33a5575ae87e23ddb.zip FreeBSD-src-2fd21198ee670ba90a6e8dc33a5575ae87e23ddb.tar.gz |
Catch malloc(3) errors and socket(2) errors
- malloc failing will result in a delayed segfault
- socket failing will result in delayed failures with setsockopt
Exit in the event that either of these high-level conditions are met.
Reported by: Coverity
CID: 976288, 976321, 976858
Sponsored by: EMC / Isilon Storage Division
Diffstat (limited to 'usr.sbin/rpcbind/util.c')
-rw-r--r-- | usr.sbin/rpcbind/util.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/usr.sbin/rpcbind/util.c b/usr.sbin/rpcbind/util.c index 25adcfc..e80c748 100644 --- a/usr.sbin/rpcbind/util.c +++ b/usr.sbin/rpcbind/util.c @@ -336,6 +336,7 @@ network_init(void) if (local_in4 == NULL) { if (debugging) fprintf(stderr, "can't alloc local ip4 addr\n"); + exit(1); } memcpy(local_in4, res->ai_addr, sizeof *local_in4); } @@ -351,6 +352,7 @@ network_init(void) if (local_in6 == NULL) { if (debugging) fprintf(stderr, "can't alloc local ip6 addr\n"); + exit(1); } memcpy(local_in6, res->ai_addr, sizeof *local_in6); } @@ -365,6 +367,11 @@ network_init(void) inet_pton(AF_INET6, RPCB_MULTICAST_ADDR, &mreq6.ipv6mr_multiaddr); s = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP); + if (s == -1) { + if (debugging) + fprintf(stderr, "couldn't create ip6 socket"); + exit(1); + } /* * Loop through all interfaces. For each IPv6 multicast-capable |