[PATCH] Ensure zero termination in string/test-s*.c (was Re: segfault in test-strcmp)
Joseph S. Myers
jsm28@cam.ac.uk
Fri Nov 8 14:42:00 GMT 2002
On Fri, 8 Nov 2002, Jakub Jelinek wrote:
> For the str* functions which don't necessarily process source strings until
> '\0' I've added stupid_st* implementations which call strlen on the strings
> first and after fixing all the do_random_tests routines which allowed
> possibly non-terminated I've tested them with IMPL (stupid_st*, 1)
> to see whether this problem doesn't occur any longer (even with
> --iterations 1000000).
strncpy, strncmp, strncat take a source that is described in C99 as an
"array", not a string, so need not be terminated. (Though in the absence
of a null character strncmp might compare up to n characters even though
the first difference is much earlier.)
--
Joseph S. Myers
jsm28@cam.ac.uk
More information about the Libc-alpha
mailing list