projects
/
gnulib.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
NEWS.stable: log cherry-pick [872f360]->[8248d1a] Copyright: Use LGPL 2.1 instead...
[gnulib.git]
/
tests
/
test-strstr.c
diff --git
a/tests/test-strstr.c
b/tests/test-strstr.c
index
718ead7
..
d6d6639
100644
(file)
--- a/
tests/test-strstr.c
+++ b/
tests/test-strstr.c
@@
-232,6
+232,14
@@
main (int argc, char *argv[])
}
{
}
{
+ /* Same bug, shorter trigger. */
+ const char *haystack = "..wi.d.";
+ const char *needle = ".d.";
+ const char* p = strstr (haystack, needle);
+ ASSERT (p - haystack == 4);
+ }
+
+ {
/* Like the above, but trigger the flaw in two_way_long_needle
by using a needle of length LONG_NEEDLE_THRESHOLD (32) or greater.
Rather than trying to find the right alignment manually, I've
/* Like the above, but trigger the flaw in two_way_long_needle
by using a needle of length LONG_NEEDLE_THRESHOLD (32) or greater.
Rather than trying to find the right alignment manually, I've
@@
-248,16
+256,18
@@
main (int argc, char *argv[])
"with_e_\n"
"..............................\n"
"with_FGHIJKLMNOPQRSTUVWXYZ\n"
"with_e_\n"
"..............................\n"
"with_FGHIJKLMNOPQRSTUVWXYZ\n"
- "with_567890123456789\n" "with_multilib_list\n";
+ "with_567890123456789\n"
+ "with_multilib_list\n";
size_t h_len = strlen (h);
char *haystack = malloc (h_len + 1);
size_t h_len = strlen (h);
char *haystack = malloc (h_len + 1);
- ASSERT (haystack);
size_t i;
size_t i;
+ ASSERT (haystack);
for (i = 0; i < h_len - strlen (needle); i++)
{
for (i = 0; i < h_len - strlen (needle); i++)
{
+ const char *p;
memcpy (haystack, h, h_len + 1);
memcpy (haystack + i, needle, strlen (needle) + 1);
memcpy (haystack, h, h_len + 1);
memcpy (haystack + i, needle, strlen (needle) + 1);
-
const char *
p = strstr (haystack, needle);
+ p = strstr (haystack, needle);
ASSERT (p);
ASSERT (p - haystack == i);
}
ASSERT (p);
ASSERT (p - haystack == i);
}