Module Name: src Committed By: christos Date: Wed May 28 14:49:28 UTC 2014
Modified Files: src/lib/libc/rpc: svc_generic.c Log Message: CID 975117: check listen(2) return . To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/lib/libc/rpc/svc_generic.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/libc/rpc/svc_generic.c diff -u src/lib/libc/rpc/svc_generic.c:1.15 src/lib/libc/rpc/svc_generic.c:1.16 --- src/lib/libc/rpc/svc_generic.c:1.15 Mon Mar 11 16:19:29 2013 +++ src/lib/libc/rpc/svc_generic.c Wed May 28 10:49:28 2014 @@ -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 @@ svc_tli_create( 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 @@ svc_tli_create( __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.