# define CHAR char
# define UCHAR unsigned char
# define SIMPLE_STRNCAT simple_strncat
+# define STRNLEN strnlen
# define STRLEN strlen
# define MEMSET memset
# define MEMCPY memcpy
# define CHAR wchar_t
# define UCHAR wchar_t
# define SIMPLE_STRNCAT simple_wcsncat
+# define STRNLEN wcsnlen
# define STRLEN wcslen
# define MEMSET wmemset
# define MEMCPY wmemcpy
return;
}
- size_t len = STRLEN (src);
+ size_t len = STRNLEN (src, n);
if (MEMCMP (dst + k, src, len + 1 > n ? n : len + 1) != 0)
{
error (0, 0, "Incorrect concatenation in function %s",
}
static void
+do_test_src_no_nullterm_bz30065 (void)
+{
+ /* NB: "src does not need to be null-terminated if it contains n or more
+ * bytes." */
+ CHAR *s1, *s2;
+ size_t bound = page_size / sizeof (CHAR);
+ s1 = (CHAR *) (buf1 + BUF1PAGES * page_size);
+ s2 = (CHAR *) buf2;
+ MEMSET (s1 - bound, -1, bound);
+ for (size_t n = 0; n < bound; ++n)
+ {
+ FOR_EACH_IMPL (impl, 0)
+ {
+ s2[0] = '\0';
+ do_one_test (impl, s2, s1 - n, n);
+ }
+ }
+}
+
+static void
do_test (size_t align1, size_t align2, size_t len1, size_t len2,
size_t n, int max_char)
{
do_random_tests ();
do_overflow_tests ();
+ do_test_src_no_nullterm_bz30065 ();
return ret;
}
salq $2, %rdx
# else
test %rdx, %rdx
- jl L(zero_len)
+ jle L(zero_len)
# endif
vpxor %VZERO_128, %VZERO_128, %VZERO_128
subl %esi, %r8d
andl $(VEC_SIZE - 1), %r8d
cmpq %r8, %rdx
- jb L(page_cross_small)
+ jbe L(page_cross_small)
/* Optimizing more aggressively for space as this is very cold
code. This saves 2x cache lines. */