Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 19 Apr 2016 23:59:10 +0000 (UTC)
From:      Garrett Cooper <ngie@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r298311 - head/lib/libc/tests/stdio
Message-ID:  <201604192359.u3JNxAhP000428@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201604192359.u3JNxAhP000428>