From fdd58dc338b5d1797bb7f44f2602ed60b1c7b911 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Tue, 16 Jul 2019 14:50:41 -0700 Subject: 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 --- tests/grep.test | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tests') 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" "" -- cgit v1.2.3