diff options
author | Bastian Beischer <bastian.beischer@rwth-aachen.de> | 2016-08-13 18:53:36 -0700 |
---|---|---|
committer | Jim Meyering <meyering@fb.com> | 2016-08-13 21:56:14 -0700 |
commit | 1a0df4396ebe3b9a58b882bb976cfce3f50d3cac (patch) | |
tree | 18ff5a1de4c7147f1009385cae83939742025d76 /tests | |
parent | 88d911dbc717494febee4b0ebc790808054fefff (diff) | |
download | diffutils-1a0df4396ebe3b9a58b882bb976cfce3f50d3cac.tar.gz |
diff3: fix heap use-after-free; add minimal diff3 test coverage
Commit v3.3-42-g3b74a90, "FIXME: src/diff3: plug a leak" added an
invalid use of free, leading to use-after-free in nearly any invocation
of diff3. Revert that commit.
* NEWS (Bug fixes): Mention it.
* tests/diff3: New file, to add minimal test coverage.
* tests/Makefile.am (TESTS): Add it.
Reported by Bastian Beischer in http://bugs.gnu.org/24210
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.am | 1 | ||||
-rw-r--r-- | tests/diff3 | 30 |
2 files changed, 31 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index 77d9fc3..66e25a5 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -6,6 +6,7 @@ TESTS = \ binary \ brief-vs-stat-zero-kernel-lies \ colliding-file-names \ + diff3 \ excess-slash \ help-version \ function-line-vs-leading-space \ diff --git a/tests/diff3 b/tests/diff3 new file mode 100644 index 0000000..a1fc287 --- /dev/null +++ b/tests/diff3 @@ -0,0 +1,30 @@ +#!/bin/sh +# This would malfunction in diff-3.4 + +. "${srcdir=.}/init.sh"; path_prepend_ ../src + +echo a > a || framework_failure_ +echo b > b || framework_failure_ +echo c > c || framework_failure_ +cat <<'EOF' > exp || framework_failure_ +==== +1:1c + a +2:1c + b +3:1c + c +EOF + +fail=0 + +diff3 a b c > out 2> err || fail=1 +compare exp out || fail=1 +compare /dev/null err || fail=1 + +# Repeat, but with all three files the same: +diff3 a a a > out 2> err || fail=1 +compare /dev/null out || fail=1 +compare /dev/null err || fail=1 + +Exit $fail |