This is the mail archive of the libc-alpha@sourceware.cygnus.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Ad PR libc/1730: glibc bug in memmem()


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]