diff options
author | Jörg Frings-Fürst <debian@jff.email> | 2022-02-07 06:57:44 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff.email> | 2022-02-07 06:57:44 +0100 |
commit | 6ffaa52cf732a84c0f8259dbc9b8183960ec5c33 (patch) | |
tree | d3136c22e3e805cfc0efe78412cce905a17e0c8d /tests/test-strstr.c | |
parent | 591cbf5878b7d4105b275585b9db1324c9dfce56 (diff) | |
parent | af151c593704a40e10efb28d1e3dd59a23a661f3 (diff) |
Merge branch 'release/debian/1.0-1'debian/1.0-1
Diffstat (limited to 'tests/test-strstr.c')
-rw-r--r-- | tests/test-strstr.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/tests/test-strstr.c b/tests/test-strstr.c index 5ba6cb8..046439b 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; } |