From be8efac78d067c138ad8dda03df4336e73f94887 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sat, 8 Jan 2022 11:51:07 +0100 Subject: New upstream version 1.0 --- tests/test-strstr.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'tests/test-strstr.c') 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 . This is a bug in memchr(), see the Austin Group's clarification - . */ + . */ 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; } -- cgit v1.2.3