Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/rpcbind CID 1338514: Check NULL returns



details:   https://anonhg.NetBSD.org/src/rev/6baceeb23866
branches:  trunk
changeset: 341528:6baceeb23866
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Nov 10 18:04:51 2015 +0000

description:
CID 1338514: Check NULL returns

diffstat:

 usr.sbin/rpcbind/rpcb_svc_com.c |  15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

diffs (36 lines):

diff -r b9a9727adaa0 -r 6baceeb23866 usr.sbin/rpcbind/rpcb_svc_com.c
--- a/usr.sbin/rpcbind/rpcb_svc_com.c   Tue Nov 10 18:01:16 2015 +0000
+++ b/usr.sbin/rpcbind/rpcb_svc_com.c   Tue Nov 10 18:04:51 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rpcb_svc_com.c,v 1.17 2015/11/08 16:36:28 christos Exp $       */
+/*     $NetBSD: rpcb_svc_com.c,v 1.18 2015/11/10 18:04:51 christos Exp $       */
 
 /*
  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -1080,7 +1080,7 @@
        struct pollfd *pollfds;
        int npollfds;
        int poll_ret, check_ret;
-       int n, m;
+       int n, *m;
 #ifdef SVC_RUN_DEBUG
        int i;
 #endif
@@ -1095,8 +1095,15 @@
                        pollfds = realloc(pollfds, npollfds * sizeof(*pollfds));
                }
                p = pollfds;
-               m = *svc_fdset_getmax();
-               for (n = 0; n <= m; n++) {
+               if (p == NULL) {
+out:
+                       syslog(LOG_ERR, "Cannot allocate pollfds");
+                       sleep(1);
+                       continue;
+               }
+               if ((m = svc_fdset_getmax()) == NULL)
+                       goto out;
+               for (n = 0; n <= *m; n++) {
                        if (svc_fdset_isset(n)) {
                                p->fd = n;
                                p->events = MASKVAL;



Home | Main Index | Thread Index | Old Index