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
This commit is contained in:
parent
02abd40029
commit
c1755e5189
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=298311
@ -250,12 +250,14 @@ ATF_TC_BODY(test_append_binary_pos, tc)
|
|||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
||||||
fp = fmemopen(NULL, 16, "ab+");
|
fp = fmemopen(NULL, 16, "ab+");
|
||||||
|
ATF_REQUIRE(fp != NULL);
|
||||||
ATF_REQUIRE(ftell(fp) == 0L);
|
ATF_REQUIRE(ftell(fp) == 0L);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
/* Make sure that a pre-allocated buffer behaves correctly. */
|
/* Make sure that a pre-allocated buffer behaves correctly. */
|
||||||
char buf[] = "Hello";
|
char buf[] = "Hello";
|
||||||
fp = fmemopen(buf, sizeof(buf), "ab+");
|
fp = fmemopen(buf, sizeof(buf), "ab+");
|
||||||
|
ATF_REQUIRE(fp != NULL);
|
||||||
ATF_REQUIRE(ftell(fp) == strlen(buf));
|
ATF_REQUIRE(ftell(fp) == strlen(buf));
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user