aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2019-07-16 14:50:41 -0700
committerRob Landley <rob@landley.net>2019-07-16 23:10:54 -0500
commitfdd58dc338b5d1797bb7f44f2602ed60b1c7b911 (patch)
tree3344059ce510d11bb919ce4b107f1dce74291a6d /tests
parenta61cb72deaefe4e6d6ac97a3776ea3c58502766d (diff)
downloadtoybox-fdd58dc338b5d1797bb7f44f2602ed60b1c7b911.tar.gz
grep: fix two bugs found by hwasan.
The first bug appeared as a memory overwrite, but was actually visible without hwasan: basically any `grep -F` that let to multiple matches on the same line was broken. The second bug was another memory overwrite, visible when I ran the existing grep tests. Bug: http://b/137573082
Diffstat (limited to 'tests')
-rwxr-xr-xtests/grep.test13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/grep.test b/tests/grep.test
index 68c8dd85..76f406c8 100755
--- a/tests/grep.test
+++ b/tests/grep.test
@@ -184,3 +184,16 @@ ln -s ../dir sub/link
testing "" "grep -rh hello sub" "" "" ""
testing "" "grep -Rh hello sub" "hello\n" "" ""
rm -rf sub real
+
+# -F multiple matches
+testing "-F multiple" "grep -F h input" "this is hello\nthis is world\n" \
+ "missing\nthis is hello\nthis is world\nmissing" ""
+testing "-Fi multiple" "grep -Fi h input" "this is HELLO\nthis is WORLD\n" \
+ "missing\nthis is HELLO\nthis is WORLD\nmissing" ""
+testing "-F empty multiple" "grep -Fi '' input" \
+ "missing\nthis is HELLO\nthis is WORLD\nmissing\n" \
+ "missing\nthis is HELLO\nthis is WORLD\nmissing" ""
+testing "-Fx" "grep -Fx h input" "h\n" \
+ "missing\nH\nthis is hello\nthis is world\nh\nmissing" ""
+testing "-Fix" "grep -Fix h input" "H\nh\n" \
+ "missing\nH\nthis is HELLO\nthis is WORLD\nh\nmissing" ""