This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]