svn commit: r298366 - head/contrib/netbsd-tests/lib/libc/sys
Garrett Cooper
ngie at FreeBSD.org
Wed Apr 20 20:43:06 UTC 2016
Author: ngie
Date: Wed Apr 20 20:43:05 2016
New Revision: 298366
URL: https://svnweb.freebsd.org/changeset/base/298366
Log:
Fix coverity issues with contrib/netbsd-tests/lib/libc/sys/t_connect.c
- Ensure socket(2) calls succeed
- Don't leak slist allocated by earlier socket(2) call
MFC after: 2 weeks
CID: 976773, 1251405
Reported by: Coverity
Sponsored by: EMC / Isilon Storage Division
Modified:
head/contrib/netbsd-tests/lib/libc/sys/t_connect.c
Modified: head/contrib/netbsd-tests/lib/libc/sys/t_connect.c
==============================================================================
--- head/contrib/netbsd-tests/lib/libc/sys/t_connect.c Wed Apr 20 20:37:58 2016 (r298365)
+++ head/contrib/netbsd-tests/lib/libc/sys/t_connect.c Wed Apr 20 20:43:05 2016 (r298366)
@@ -56,6 +56,11 @@ ATF_TC_BODY(connect_low_port, tc)
slist = socket(AF_INET, SOCK_STREAM, 0);
sd = socket(AF_INET, SOCK_STREAM, 0);
+#ifdef __FreeBSD__
+ ATF_REQUIRE(sd > 0);
+ ATF_REQUIRE(slist > 0);
+#endif
+
/* bind listening socket */
memset(&sinlist, 0, sizeof(sinlist));
sinlist.sin_family = AF_INET;
@@ -92,6 +97,9 @@ ATF_TC_BODY(connect_low_port, tc)
ATF_REQUIRE(ntohs(sin.sin_port) <= IPPORT_RESERVEDMAX);
close(sd);
+#ifdef __FreeBSD__
+ close(slist);
+#endif
}
ATF_TP_ADD_TCS(tp)
More information about the svn-src-head
mailing list