[LTP] [PATCH v1 3/3] syscalls/mallinfo03: Add an overflow test when setting 2G size

Li Wang liwang@redhat.com
Thu Feb 4 09:54:53 CET 2021


Hi Xu,


> +void test_mallinfo(void)
> +{
> +       struct mallinfo info;
> +       char *buf;
> +       size_t size = 2UL * 1024UL * 1024UL * 1024UL;
> +
> +       buf = SAFE_MALLOC(size);
> +       info = mallinfo();
> +       if (info.hblkhd < 0) {
> +               print_mallinfo("Test malloc 2G", &info);
> +               tst_res(TFAIL, "The member of struct mallinfo overflow, we
> should use mallinfo2");
>

TPASS?


> +       } else {
> +               /*We will never get here*/
> +               tst_res(TPASS, "The member of struct mallinfo doesn't
> overflow");
>

TFAIL?



> +       }
> +       free(buf);
> +}
>


-- 
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20210204/101b8c8d/attachment.htm>


More information about the ltp mailing list