svn commit: r298311 - head/lib/libc/tests/stdio

Garrett Cooper ngie at FreeBSD.org
Tue Apr 19 23:59:11 UTC 2016


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);
 }


More information about the svn-src-head mailing list