svn commit: r300932 - head/usr.sbin/rpcbind

2016-05-29 Thread Garrett Cooper
Author: ngie
Date: Sun May 29 03:42:50 2016
New Revision: 300932
URL: https://svnweb.freebsd.org/changeset/base/300932

Log:
  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

Modified:
  head/usr.sbin/rpcbind/util.c

Modified: head/usr.sbin/rpcbind/util.c
==
--- head/usr.sbin/rpcbind/util.cSun May 29 02:59:03 2016
(r300931)
+++ head/usr.sbin/rpcbind/util.cSun May 29 03:42:50 2016
(r300932)
@@ -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, _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
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r300932 - head/usr.sbin/rpcbind

2016-05-29 Thread Bryan Drewery
On 5/28/2016 8:42 PM, Garrett Cooper wrote:
> Author: ngie
> Date: Sun May 29 03:42:50 2016
> New Revision: 300932
> URL: https://svnweb.freebsd.org/changeset/base/300932
> 
> Log:
>   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
> 
> Modified:
>   head/usr.sbin/rpcbind/util.c
> 
> Modified: head/usr.sbin/rpcbind/util.c
> ==
> --- head/usr.sbin/rpcbind/util.c  Sun May 29 02:59:03 2016
> (r300931)
> +++ head/usr.sbin/rpcbind/util.c  Sun May 29 03:42:50 2016
> (r300932)
> @@ -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);

Did something meaningful get printed before this on hitting this error,
without debug?

>   }
>   memcpy(local_in6, res->ai_addr, sizeof *local_in6);
>   }
> @@ -365,6 +367,11 @@ network_init(void)
>   inet_pton(AF_INET6, RPCB_MULTICAST_ADDR, _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
> 


-- 
Regards,
Bryan Drewery



signature.asc
Description: OpenPGP digital signature


Re: svn commit: r300932 - head/usr.sbin/rpcbind

2016-05-28 Thread Ngie Cooper (yaneurabeya)

> On May 28, 2016, at 20:44, Bryan Drewery  wrote:
> 
> On 5/28/2016 8:42 PM, Garrett Cooper wrote:
>> Author: ngie
>> Date: Sun May 29 03:42:50 2016
>> New Revision: 300932
>> URL: https://svnweb.freebsd.org/changeset/base/300932
>> 
>> Log:
>>  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
>> 
>> Modified:
>>  head/usr.sbin/rpcbind/util.c
>> 
>> Modified: head/usr.sbin/rpcbind/util.c
>> ==
>> --- head/usr.sbin/rpcbind/util.c Sun May 29 02:59:03 2016
>> (r300931)
>> +++ head/usr.sbin/rpcbind/util.c Sun May 29 03:42:50 2016
>> (r300932)
>> @@ -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);
> 
> Did something meaningful get printed before this on hitting this error,
> without debug?

Nope. It just crashed.. I’ve briefly thought about it, and I think that 
err/errx would be better. I’ll run some more tests/fix some more Coverity 
issues in the area, and send it out for CR.
Thanks,
-Ngie


signature.asc
Description: Message signed with OpenPGP using GPGMail