This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Broken strncat macro
- To: libc-alpha at sources dot redhat dot com
- Subject: Broken strncat macro
- From: "Joseph S. Myers" <jsm28 at cam dot ac dot uk>
- Date: Sat, 28 Oct 2000 22:05:03 +0100 (BST)
glibc's strncat macro is broken on i686-linux when you define
__USE_STRING_INLINES: it fails to append the terminating null character
when the length to concatenate is less than the string length. This
applies both to <bits/string.h>'s version and to that in <bits/string2.h>
if _HAVE_STRING_ARCH_strchr is defined.
Testcase:
#define __USE_STRING_INLINES
#include <string.h>
#include <stdlib.h>
char d[3] = "\0\1\2";
int
main (void)
{
strncat (d, "\5\6", 1);
if (d[0] != 5 || d[1] != 0 || d[2] != 2)
abort ();
exit (0);
}
--
Joseph S. Myers
jsm28@cam.ac.uk