Created attachment 7749 [details]
Using SIZE_MAX as third argument to strncat() should behave as if strcat() was used.
According to POSIX (http://pubs.opengroup.org/onlinepubs/009695399/functions/strncat.html),
"The strncat() function shall append not more than n bytes (a null byte and bytes that follow it are not appended) from the array pointed to by s2 to the end of the string pointed to by s1."
The wording imply that the third "n" argument is an additional boundary limit, not the destination buffer capacity (ie. the destination buffer is not implicitly SIZE_MAX), and both source and destination do not overlap (overlapping depends on the source and destination layout, not on the "n" value)
However, it seems that the optimized strncat version of the GLIBC behaves incorrectly, when using this value.
The culprit might be in the sysdeps/x86_64/multiarch/strcat-sse2-unaligned.S source file (see https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86_64/multiarch/strcat-sse2-unaligned.S;h=dc782f2c2370915f74673ff8184e5f2eaf2795db;hb=HEAD)
See also the comp.unix.programmer related discussion, with a possible location of the bug in the assembly source:
Marking as duplicate of BZ#19390.
*** This bug has been marked as a duplicate of bug 19390 ***