Ad PR libc/1730: glibc bug in memmem()
Greg Hudson
ghudson@MIT.EDU
Wed May 17 07:06:00 GMT 2000
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.
More information about the Libc-alpha
mailing list