pf tests: Try to provoke a memory leak

There was a memory leak in the DIOCRADDTABLES ioctl() code which could
be triggered by trying to add tables with the same name.
Try to provoke this memory leak. It was fixed in r331225.

MFC after:	1 week
This commit is contained in:
Kristof Provost 2018-04-06 19:22:22 +00:00
parent 8e748b94e7
commit 1bb72c2943
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=332139

View File

@ -66,6 +66,7 @@ ATF_TC_BODY(addtables, tc)
{
struct pfioc_table io;
struct pfr_table tbl;
struct pfr_table tbls[4];
int flags;
COMMON_HEAD();
@ -93,6 +94,14 @@ ATF_TC_BODY(addtables, tc)
if (ioctl(dev, DIOCRADDTABLES, &io) == 0)
atf_tc_fail("Request with NULL buffer succeeded");
/* This can provoke a memory leak, see r331225. */
io.pfrio_size = 4;
for (int i = 0; i < io.pfrio_size; i++)
common_init_tbl(&tbls[i]);
io.pfrio_buffer = &tbls;
ioctl(dev, DIOCRADDTABLES, &io);
COMMON_CLEANUP();
}