summaryrefslogtreecommitdiff
path: root/tests/test-strstr.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2022-01-08 11:51:07 +0100
committerJörg Frings-Fürst <debian@jff.email>2022-01-08 11:51:07 +0100
commitbe8efac78d067c138ad8dda03df4336e73f94887 (patch)
tree5f5254a628ba0ef72065b93d949d1c985742ea8e /tests/test-strstr.c
parent7b65dbd4ebade81d504cfe5e681292a58ad1fdf0 (diff)
New upstream version 1.0upstream/1.0
Diffstat (limited to 'tests/test-strstr.c')
-rw-r--r--tests/test-strstr.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/tests/test-strstr.c b/tests/test-strstr.c
index 5ba6cb82..046439ba 100644
--- a/tests/test-strstr.c
+++ b/tests/test-strstr.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004, 2007-2018 Free Software Foundation, Inc.
+ * Copyright (C) 2004, 2007-2022 Free Software Foundation, Inc.
* Written by Bruno Haible and Eric Blake
*
* This program is free software: you can redistribute it and/or modify
@@ -60,7 +60,7 @@ main (int argc, char *argv[])
read access for strstr().
See <https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=521737>.
This is a bug in memchr(), see the Austin Group's clarification
- <http://www.opengroup.org/austin/docs/austin_454.txt>. */
+ <https://www.opengroup.org/austin/docs/austin_454.txt>. */
const char *fix = "aBaaaaaaaaaaax";
char *page_boundary = (char *) zerosize_ptr ();
size_t len = strlen (fix) + 1;
@@ -275,5 +275,27 @@ main (int argc, char *argv[])
free (haystack);
}
+ /* Test long needles. */
+ {
+ size_t m = 1024;
+ char *haystack = (char *) malloc (2 * m + 1);
+ char *needle = (char *) malloc (m + 1);
+ if (haystack != NULL && needle != NULL)
+ {
+ const char *p;
+ haystack[0] = 'x';
+ memset (haystack + 1, ' ', m - 1);
+ memset (haystack + m, 'x', m);
+ haystack[2 * m] = '\0';
+ memset (needle, 'x', m);
+ needle[m] = '\0';
+ p = strstr (haystack, needle);
+ ASSERT (p);
+ ASSERT (p - haystack == m);
+ }
+ free (needle);
+ free (haystack);
+ }
+
return 0;
}