This is the mail archive of the
libc-alpha@sourceware.cygnus.com
mailing list for the glibc project.
Re: Ad PR libc/1730: glibc bug in memmem()
- To: Andreas Jaeger <aj at suse dot de>
- Subject: Re: Ad PR libc/1730: glibc bug in memmem()
- From: Greg Hudson <ghudson at MIT dot EDU>
- Date: Wed, 17 May 2000 10:06:04 -0400
- cc: libc-alpha Mailinglist <libc-alpha at sourceware dot cygnus dot com>
The code part of the patch looks fine. (I would probably avoid even
computing the invalid pointer value in the haystack_len < needle_len,
but I hardly think that's important.)
> * sysdeps/generic/memmem.c (memmem): Check for invalid parameter.
I don't think having haystack_len < needle_len constitutes an invalid
parameter.
> + /* Sanity check, otherwise the loop will search through the whole
> + memory. */
This comment might be confusing to some readers. On most C
implementations, most of the time, the loop will not search through
the whole memory. The particular case that bit me was that haystack
was NULL (the result of malloc(0)), so the invalid computed pointer
wrapped around to a very high value.
Replacing "will" with "might" would probably fix the situation.
Sorry to nitpick so much. Thanks for your time.