Date: Wed, 4 May 2016 00:30:36 +0000 (UTC) From: Garrett Cooper <ngie@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r299021 - stable/10/lib/libc/tests/stdio Message-ID: <201605040030.u440UaUQ047808@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ngie Date: Wed May 4 00:30:36 2016 New Revision: 299021 URL: https://svnweb.freebsd.org/changeset/base/299021 Log: MFC r298311,r298312: r298311: Make sure fmemopen succeeds in :test_append_binary_pos before calling ftell on the FILE object This fixes potential null pointer dereferences on failure CID: 1254952 r298312: Fix double fclose of `fp1` when freopen fails freopen handles closing file descriptors on error, with the exception of fdopen'ed descriptors, so closing an already fclose'd file descriptor is incorrect CID: 1338525 Modified: stable/10/lib/libc/tests/stdio/fmemopen2_test.c stable/10/lib/libc/tests/stdio/freopen_test.c Directory Properties: stable/10/ (props changed) Modified: stable/10/lib/libc/tests/stdio/fmemopen2_test.c ============================================================================== --- stable/10/lib/libc/tests/stdio/fmemopen2_test.c Wed May 4 00:29:05 2016 (r299020) +++ stable/10/lib/libc/tests/stdio/fmemopen2_test.c Wed May 4 00:30:36 2016 (r299021) @@ -249,12 +249,14 @@ ATF_TC_BODY(test_append_binary_pos, tc) FILE *fp; fp = fmemopen(NULL, 16, "ab+"); + ATF_REQUIRE(fp != NULL); ATF_REQUIRE(ftell(fp) == 0L); fclose(fp); /* Make sure that a pre-allocated buffer behaves correctly. */ char buf[] = "Hello"; fp = fmemopen(buf, sizeof(buf), "ab+"); + ATF_REQUIRE(fp != NULL); ATF_REQUIRE(ftell(fp) == strlen(buf)); fclose(fp); } Modified: stable/10/lib/libc/tests/stdio/freopen_test.c ============================================================================== --- stable/10/lib/libc/tests/stdio/freopen_test.c Wed May 4 00:29:05 2016 (r299020) +++ stable/10/lib/libc/tests/stdio/freopen_test.c Wed May 4 00:30:36 2016 (r299021) @@ -48,7 +48,6 @@ runtest(const char *fname1, const char * "fopen(\"%s\", \"%s\") failed; errno=%d", fname1, mode1, errno); fp2 = freopen(fname2, mode2, fp1); if (fp2 == NULL) { - fclose(fp1); ATF_REQUIRE_MSG(success == false, "freopen(\"%s\", \"%s\", fopen(\"%s\", \"%s\")) succeeded " "unexpectedly", fname2_print, mode2, fname1, mode1);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201605040030.u440UaUQ047808>