This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: [PATCH] Ensure zero termination in string/test-s*.c (was Re:segfault in test-strcmp)
- From: "Joseph S. Myers" <jsm28 at cam dot ac dot uk>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: Roland McGrath <roland at redhat dot com>, Jack Howarth <howarth at bromo dot med dot uc dot edu>, <libc-alpha at sources dot redhat dot com>
- Date: Fri, 8 Nov 2002 22:28:26 +0000 (GMT)
- Subject: Re: [PATCH] Ensure zero termination in string/test-s*.c (was Re:segfault in test-strcmp)
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