summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorngie <ngie@FreeBSD.org>2016-04-19 23:59:10 +0000
committerngie <ngie@FreeBSD.org>2016-04-19 23:59:10 +0000
commitef837f8229b78347a7fa76948f495fc09df2ec2e (patch)
treed44877d4c066a74eb86d9c1c9d5bd17d7146407c /lib
parenta7d40a88c91d105dcfe2f235bc84a522bfea3de2 (diff)
downloadFreeBSD-src-ef837f8229b78347a7fa76948f495fc09df2ec2e.zip
FreeBSD-src-ef837f8229b78347a7fa76948f495fc09df2ec2e.tar.gz
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
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/tests/stdio/fmemopen2_test.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/libc/tests/stdio/fmemopen2_test.c b/lib/libc/tests/stdio/fmemopen2_test.c
index c3aa6c5..a2ca325 100644
--- a/lib/libc/tests/stdio/fmemopen2_test.c
+++ b/lib/libc/tests/stdio/fmemopen2_test.c
@@ -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);
}
OpenPOWER on IntegriCloud