Blame SOURCES/cve-2022-1271-part2.patch

7c747d
From d74a30d45c6834c8e9f87115197370fe86656d81 Mon Sep 17 00:00:00 2001
7c747d
From: Jim Meyering <meyering@fb.com>
7c747d
Date: Mon, 4 Apr 2022 23:52:49 -0700
7c747d
Subject: zgrep: add NEWS and tests for this exploitable bug
7c747d
7c747d
* tests/zgrep-abuse: New file, based on PoC by cleemy desu wayo.
7c747d
* tests/Makefile.am (TESTS): Add it.
7c747d
* NEWS: Mention the exploit.
7c747d
The bug appears to have been present since the beginning.
7c747d
---
7c747d
 tests/Makefile.am |  1 +
7c747d
 tests/zgrep-abuse | 41 +++++++++++++++++++++++++++++++++++++++++
7c747d
 3 files changed, 45 insertions(+)
7c747d
 create mode 100755 tests/zgrep-abuse
7c747d
7c747d
diff --git a/tests/Makefile.am b/tests/Makefile.am
7c747d
index d09672e..5f148d6 100644
7c747d
--- a/tests/Makefile.am
7c747d
+++ b/tests/Makefile.am
7c747d
@@ -36,6 +36,7 @@ TESTS =					\
7c747d
   z-suffix				\
7c747d
   zdiff					\
7c747d
   zgrep-f				\
7c747d
+  zgrep-abuse				\
7c747d
   zgrep-context				\
7c747d
   zgrep-signal				\
7c747d
   znew-k
7c747d
diff --git a/tests/zgrep-abuse b/tests/zgrep-abuse
7c747d
new file mode 100755
7c747d
index 0000000..3e8a8f9
7c747d
--- /dev/null
7c747d
+++ b/tests/zgrep-abuse
7c747d
@@ -0,0 +1,41 @@
7c747d
+#!/bin/sh
7c747d
+# Show how zgrep applied to a crafted file name may overwrite
7c747d
+# a selected file with chosen content.  Fixed in gzip-1.12.
7c747d
+
7c747d
+# Copyright (C) 2022 Free Software Foundation, Inc.
7c747d
+
7c747d
+# This program is free software: you can redistribute it and/or modify
7c747d
+# it under the terms of the GNU General Public License as published by
7c747d
+# the Free Software Foundation, either version 3 of the License, or
7c747d
+# (at your option) any later version.
7c747d
+
7c747d
+# This program is distributed in the hope that it will be useful,
7c747d
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
7c747d
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
7c747d
+# GNU General Public License for more details.
7c747d
+
7c747d
+# You should have received a copy of the GNU General Public License
7c747d
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
7c747d
+# limit so don't run it by default.
7c747d
+
7c747d
+. "${srcdir=.}/init.sh"; path_prepend_ ..
7c747d
+
7c747d
+: > z || framework_failure_
7c747d
+echo test |gzip > 'z|
7c747d
+p
7c747d
+1s|.*|chosen-content|
7c747d
+1w hacked
7c747d
+etouch .\x2fhacked2
7c747d
+d
7c747d
+#
7c747d
+#' || framework_failure_
7c747d
+
7c747d
+fail=0
7c747d
+
7c747d
+zgrep test z* > /dev/null
7c747d
+
7c747d
+# Before the fix, each of these would be created.
7c747d
+test -f hacked && fail=1
7c747d
+test -f hacked2 && fail=1
7c747d
+
7c747d
+Exit $fail
7c747d
-- 
7c747d
cgit v1.1
7c747d