Source-Changes-HG archive

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

[src/trunk]: src/lib/libc/rpc CID 975117: check listen(2) return .



details:   https://anonhg.NetBSD.org/src/rev/5bab8f2903b0
branches:  trunk
changeset: 796306:5bab8f2903b0
user:      christos <christos%NetBSD.org@localhost>
date:      Wed May 28 14:49:28 2014 +0000

description:
CID 975117: check listen(2) return .

diffstat:

 lib/libc/rpc/svc_generic.c |  17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)

diffs (46 lines):

diff -r 2a0792277596 -r 5bab8f2903b0 lib/libc/rpc/svc_generic.c
--- a/lib/libc/rpc/svc_generic.c        Wed May 28 14:45:57 2014 +0000
+++ b/lib/libc/rpc/svc_generic.c        Wed May 28 14:49:28 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: svc_generic.c,v 1.15 2013/03/11 20:19:29 tron Exp $    */
+/*     $NetBSD: svc_generic.c,v 1.16 2014/05/28 14:49:28 christos Exp $        */
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = "@(#)svc_generic.c 1.21 89/02/28 Copyr 1988 Sun Micro";
 #else
-__RCSID("$NetBSD: svc_generic.c,v 1.15 2013/03/11 20:19:29 tron Exp $");
+__RCSID("$NetBSD: svc_generic.c,v 1.16 2014/05/28 14:49:28 christos Exp $");
 #endif
 #endif
 
@@ -251,7 +251,11 @@
                                        goto freedata;
                                }
                        }
-                       listen(fd, SOMAXCONN);
+                       if (listen(fd, SOMAXCONN) == -1) {
+                               warnx("%s: could not listen at anonymous port",
+                                   __func__);
+                               goto freedata;
+                       }
                } else {
                        if (bind(fd,
                            (struct sockaddr *)bindaddr->addr.buf,
@@ -260,9 +264,12 @@
                                    __func__);
                                goto freedata;
                        }
-                       listen(fd, (int)bindaddr->qlen);
+                       if (listen(fd, (int)bindaddr->qlen) == -1) {
+                               warnx("%s: could not listen at requested "
+                                   "address", __func__);
+                               goto freedata;
+                       }
                }
-                       
        }
        /*
         * call transport specific function.



Home | Main Index | Thread Index | Old Index