Hi, I originally reported this as... https://bugzilla.kernel.org/show_bug.cgi?id=42042 ... but it seems we're still waiting for bugzilla to come back after the security breach. PROBLEM ------- strchr(3) and memchr(3) do not explain the behaviour if the character to search for is specified as a null character ('\0'). According to my copy of Harbison and Steele, since the terminator is considered part of the string, a call such as: strchr("hello", '\0') ... will return the address of the terminating null in the specified string. RATIONALE --------- strchr(3) and memchr(3) are inconsistent with index(3) which states: "The terminating NULL character is considered to be a part of the strings." Adding such a note to strchr(3) and memchr(3) is also important since it is not unreasonable to assume that strchr() will return NULL in this scenario. This leads to code like the following which is guaranteed to fail should get_a_char() return '\0': char string[] = "hello, world"; int c = get_a_char(); if (! strchr(string, c)) fprintf(stderr, "failed to find character in string\n"); TEST PROGRAM ------------ The attached test program demonstrates the behaviour of strchr, strrchr, memchr, strchrnul, and strstr. Test program has run successfully on: - Ubuntu Natty (11.04) system with libc6 version 2.13-0ubuntu13 (egcs). - Fedora 15 system with glibc version 2.13.90-9. Note further that the The BSD folk already have this behaviour documented in their man pages: http://www.freebsd.org/cgi/man.cgi?query=strchr&apropos=0&sektion=0&manpath=FreeBSD+8.2-RELEASE&arch=default&format=html PATCH ----- Patch applies against latest version of man-pages git repository. An alternative to the provided patch for strchr.3 only would be to simply add the following to strchr.3 (taken from the FreeBSD man page): The terminating null character is considered part of the string; therefore if c is `\0', the functions locate the terminating `\0'. However, note that the FreeBSD man page for memchr.3 also omits to explain the behaviour should c be '\0'. This appears to be because the FreeBSD man pages are based upon the POSIX specification document which is similarly vague upon this point.