CID 1338513: Check listen(2) return

This commit is contained in:
christos 2015-11-10 18:01:16 +00:00
parent fa11598f4c
commit 5d9565aab9
1 changed files with 11 additions and 8 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: rpc_soc.c,v 1.19 2014/05/28 14:45:57 christos Exp $ */
/* $NetBSD: rpc_soc.c,v 1.20 2015/11/10 18:01:16 christos Exp $ */
/*
* Copyright (c) 2010, Oracle America, Inc.
@ -45,7 +45,7 @@
#if 0
static char sccsid[] = "@(#)rpc_soc.c 1.41 89/05/02 Copyr 1988 Sun Micro";
#else
__RCSID("$NetBSD: rpc_soc.c,v 1.19 2014/05/28 14:45:57 christos Exp $");
__RCSID("$NetBSD: rpc_soc.c,v 1.20 2015/11/10 18:01:16 christos Exp $");
#endif
#endif
@ -255,17 +255,20 @@ svc_com_create(int fd, u_int sendsize, u_int recvsize, const char *netid)
memset(&sccsin, 0, sizeof sccsin);
sccsin.sin_family = AF_INET;
(void)bindresvport(fd, &sccsin);
listen(fd, SOMAXCONN);
if (listen(fd, SOMAXCONN) == -1)
goto out;
svc = svc_tli_create(fd, nconf, NULL, sendsize, recvsize);
(void) freenetconfigent(nconf);
if (svc == NULL) {
if (madefd)
(void) close(fd);
return (NULL);
if (svc == NULL)
goto out;
}
port = (((struct sockaddr_in *)svc->xp_ltaddr.buf)->sin_port);
svc->xp_port = ntohs(port);
return (svc);
return svc;
out:
if (madefd)
(void) close(fd);
return NULL;
}
SVCXPRT *