bug-autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AC_FUNC_MEMMEM


From: Ralf Wildenhues
Subject: Re: AC_FUNC_MEMMEM
Date: Wed, 2 Jan 2008 20:27:00 +0100
User-agent: Mutt/1.5.13 (2006-08-11)

Hello Peter,

Happy New Year, and apologies for the half-year delay.

* Peter Miller wrote on Thu, Jun 28, 2007 at 07:29:06AM CEST:
> The man page for memmem(1) details numerous bugs found in previous
> versions of gnu libc:
> 
>         This function was broken in Linux libraries up to and including
>         libc 5.0.9;  there the ‘needle’ and ‘haystack’ arguments were
>         interchanged, and a pointer to the end of the first  occurrence
>         of  needle  was returned.  Since libc 5.0.9 is still widely
>         used, this is a dangerous function to use.  Both old and new
>         libc’s have the bug that if needle is empty haystack-1 (instead
>         of  haystack) is returned.  And glibc 2.0 makes it worse, and
>         returns a pointer to the last byte of ‘haystack’.  This is fixed
>         in glibc 2.1.
> 
> It would be very helpful if GNU Autoconf had a AC_FUNC_MEMMEM macro to
> detect correct memmem(3) implementations.

FWIW, gnulib has a module memmem that provides a macro gl_FUNC_MEMMEM
that should test for at least the first issue.

Please note that even glibc 2.6.1 provides an implementation of memmem
that scales quadratically in the worst case, unlike the gnulib version.

Hope that helps.

Cheers,
Ralf




reply via email to

[Prev in Thread] Current Thread [Next in Thread]