Author: ngie Date: Tue Apr 19 23:59:10 2016 New Revision: 298311 URL: https://svnweb.freebsd.org/changeset/base/298311
Log: 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 MFC after: 2 weeks Reported by: Coverity Sponsored by: EMC / Isilon Storage Division Modified: head/lib/libc/tests/stdio/fmemopen2_test.c Modified: head/lib/libc/tests/stdio/fmemopen2_test.c ============================================================================== --- head/lib/libc/tests/stdio/fmemopen2_test.c Tue Apr 19 23:48:27 2016 (r298310) +++ head/lib/libc/tests/stdio/fmemopen2_test.c Tue Apr 19 23:59:10 2016 (r298311) @@ -250,12 +250,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); } _______________________________________________ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"