Calling strcmp/strncmp/strcasecmp/strncasecmp with NULL parameter

Roland McGrath roland@redhat.com
Tue Aug 17 21:13:00 GMT 2004


> in the not so unlikely event, that one of the string compare functions is
> called with NULL as one parameter the process will get a SIGSEGV, because
> the functions are dereferencing NULL pointers (i'm referring to the funcs
> found in sysdeps/generic). I doubt this is intended behaviour, IMHO these
> function should not fail, no matter what the input is.

You are mistaken.  Most functions that take pointers have undefined
behavior when given a null pointer or any other inappropriate pointer value.
They behave just like the * operator in this regard.  Getting a SIGSEGV is
in fact the single most useful thing that could happen here.



More information about the Libc-alpha mailing list