NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: bin/51850: [PATCH] tests/lib/libc/sys/t_connect: add sys/socket.h for socket(2) and don't leak fds
The following reply was made to PR bin/51850; it has been noted by GNATS.
From: "Ngie Cooper (yaneurabeya)" <yaneurabeya%gmail.com@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc:
Subject: Re: bin/51850: [PATCH] tests/lib/libc/sys/t_connect: add sys/socket.h
for socket(2) and don't leak fds
Date: Thu, 12 Jan 2017 22:05:48 -0800
--Apple-Mail=_D4E98839-D0B0-4CFB-9B8B-98A030D6DCA2
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=us-ascii
Patch attached.
-Ngie
--Apple-Mail=_D4E98839-D0B0-4CFB-9B8B-98A030D6DCA2
Content-Disposition: attachment;
filename=t_connect-add-sys-socket-for-socket-and-close-fds.patch
Content-Type: application/octet-stream;
x-unix-mode=0644;
name="t_connect-add-sys-socket-for-socket-and-close-fds.patch"
Content-Transfer-Encoding: 7bit
Index: lib/libc/sys/t_connect.c
===================================================================
RCS file: /cvsroot/src/tests/lib/libc/sys/t_connect.c,v
retrieving revision 1.2
diff -u -r1.2 t_connect.c
--- lib/libc/sys/t_connect.c 5 Apr 2015 23:17:41 -0000 1.2
+++ lib/libc/sys/t_connect.c 13 Jan 2017 05:55:20 -0000
@@ -26,6 +26,7 @@
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <sys/socket.h>
#include <err.h>
#include <errno.h>
#include <string.h>
@@ -52,6 +53,9 @@
slist = socket(AF_INET, SOCK_STREAM, 0);
sd = socket(AF_INET, SOCK_STREAM, 0);
+ ATF_REQUIRE(sd > 0);
+ ATF_REQUIRE(slist > 0);
+
/* bind listening socket */
memset(&sinlist, 0, sizeof(sinlist));
sinlist.sin_family = AF_INET;
@@ -88,6 +92,7 @@
ATF_REQUIRE(ntohs(sin.sin_port) <= IPPORT_RESERVEDMAX);
close(sd);
+ close(slist);
}
ATF_TC(connect_foreign_family);
--Apple-Mail=_D4E98839-D0B0-4CFB-9B8B-98A030D6DCA2--
Home |
Main Index |
Thread Index |
Old Index