This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/18240] hcreate((size_t)-1) should fail with ENOMEM
- From: "fweimer at redhat dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Mon, 20 Apr 2015 08:29:14 +0000
- Subject: [Bug libc/18240] hcreate((size_t)-1) should fail with ENOMEM
- Auto-submitted: auto-generated
- References: <bug-18240-131 at http dot sourceware dot org/bugzilla/>
https://sourceware.org/bugzilla/show_bug.cgi?id=18240
--- Comment #2 from Florian Weimer <fweimer at redhat dot com> ---
Reproducer for the out-of-bounds access:
#include <err.h>
#include <errno.h>
#include <search.h>
#include <stdio.h>
int
main (void)
{
int res = hcreate (-1);
if (res == 0)
{
if (errno == ENOMEM)
return 0;
printf ("hcreate(-1): %m\n");
return 1;
}
for (int i = 0; i < 100; ++i)
{
char key[20];
snprintf (key, sizeof (key), "%d", i);
ENTRY e = { key, "value" };
if (hsearch (e, ENTER) == NULL)
{
printf ("hsearch(\"%s\"): %m\n", key);
return 1;
}
}
hdestroy ();
return 0;
}
--
You are receiving this mail because:
You are on the CC list for the bug.