Date: Wed, 4 Jan 2017 04:10:36 +0000 (UTC) From: Ngie Cooper <ngie@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r311244 - head/contrib/netbsd-tests/lib/libc/sys Message-ID: <201701040410.v044AacG072316@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ngie Date: Wed Jan 4 04:10:36 2017 New Revision: 311244 URL: https://svnweb.freebsd.org/changeset/base/311244 Log: mmap_prot_3, mmap_truncate, mmap_truncate_signal: don't leak fd and map Reported by: Coverity CID: 978306, 1251406, 1288196, 1300541 Modified: head/contrib/netbsd-tests/lib/libc/sys/t_mmap.c Modified: head/contrib/netbsd-tests/lib/libc/sys/t_mmap.c ============================================================================== --- head/contrib/netbsd-tests/lib/libc/sys/t_mmap.c Wed Jan 4 04:00:28 2017 (r311243) +++ head/contrib/netbsd-tests/lib/libc/sys/t_mmap.c Wed Jan 4 04:10:36 2017 (r311244) @@ -381,9 +381,13 @@ ATF_TC_BODY(mmap_prot_3, tc) * the access should generate SIGSEGV. */ fd = open(path, O_RDWR | O_CREAT, 0700); - if (fd < 0) +#ifdef __FreeBSD__ + atf_tc_skip("opening %s failed; skipping testcase: %s", + path, strerror(errno)); +#else return; +#endif ATF_REQUIRE(write(fd, "XXX", 3) == 3); ATF_REQUIRE(close(fd) == 0); @@ -409,6 +413,9 @@ ATF_TC_BODY(mmap_prot_3, tc) ATF_REQUIRE(WIFEXITED(sta) != 0); ATF_REQUIRE(WEXITSTATUS(sta) == SIGSEGV); ATF_REQUIRE(munmap(map, 3) == 0); +#ifdef __FreeBSD__ + (void)close(fd); +#endif } ATF_TC_CLEANUP(mmap_prot_3, tc) @@ -453,6 +460,9 @@ ATF_TC_BODY(mmap_truncate, tc) ATF_REQUIRE(ftruncate(fd, page / 12) == 0); ATF_REQUIRE(ftruncate(fd, page / 64) == 0); +#ifdef __FreeBSD__ + (void)munmap(map, page); +#endif ATF_REQUIRE(close(fd) == 0); } @@ -509,6 +519,10 @@ ATF_TC_BODY(mmap_truncate_signal, tc) prevent the access to be optimized out */ ATF_REQUIRE(i == 0); ATF_REQUIRE(sta == 0); +#ifdef __FreeBSD__ + (void)munmap(map, page); + (void)close(fd); +#endif return; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201701040410.v044AacG072316>