|
|
6c1aee8 |
commit 369dcccdfa6336e5a873d6d63705cfbe04c55727
|
|
|
6c1aee8 |
Author: Jean Delvare <jdelvare@suse.de>
|
|
|
6c1aee8 |
Date: Mon May 7 15:14:45 2018 +0200
|
|
|
6c1aee8 |
|
|
|
6c1aee8 |
Don't leak temporary file on failed multi-file ed-style patch
|
|
|
6c1aee8 |
|
|
|
6c1aee8 |
The previous fix worked fine with single-file ed-style patches, but
|
|
|
6c1aee8 |
would still leak temporary files in the case of multi-file ed-style
|
|
|
6c1aee8 |
patch. Fix that case as well, and extend the test case to check for
|
|
|
6c1aee8 |
it.
|
|
|
6c1aee8 |
|
|
|
6c1aee8 |
* src/patch.c (main): Unlink TMPEDNAME if needed before moving to
|
|
|
6c1aee8 |
the next file in a patch.
|
|
|
6c1aee8 |
|
|
|
6c1aee8 |
This closes bug #53820:
|
|
|
6c1aee8 |
https://savannah.gnu.org/bugs/index.php?53820
|
|
|
6c1aee8 |
|
|
|
6c1aee8 |
Fixes: 123eaff0d5d1 ("Fix arbitrary command execution in ed-style patches (CVE-2018-1000156)")
|
|
|
6c1aee8 |
Fixes: 19599883ffb6 ("Don't leak temporary file on failed ed-style patch")
|
|
|
6c1aee8 |
|
|
|
6c1aee8 |
diff --git a/src/patch.c b/src/patch.c
|
|
|
6c1aee8 |
index 9146597..81c7a02 100644
|
|
|
6c1aee8 |
--- a/src/patch.c
|
|
|
6c1aee8 |
+++ b/src/patch.c
|
|
|
6c1aee8 |
@@ -236,6 +236,7 @@ main (int argc, char **argv)
|
|
|
6c1aee8 |
}
|
|
|
6c1aee8 |
remove_if_needed (TMPOUTNAME, &TMPOUTNAME_needs_removal);
|
|
|
6c1aee8 |
}
|
|
|
6c1aee8 |
+ remove_if_needed (TMPEDNAME, &TMPEDNAME_needs_removal);
|
|
|
6c1aee8 |
|
|
|
6c1aee8 |
if (! skip_rest_of_patch && ! file_type)
|
|
|
6c1aee8 |
{
|
|
|
6c1aee8 |
diff --git a/tests/ed-style b/tests/ed-style
|
|
|
6c1aee8 |
index 6b6ef9d..504e6e5 100644
|
|
|
6c1aee8 |
--- a/tests/ed-style
|
|
|
6c1aee8 |
+++ b/tests/ed-style
|
|
|
6c1aee8 |
@@ -38,3 +38,34 @@ EOF
|
|
|
6c1aee8 |
check 'cat foo' <
|
|
|
6c1aee8 |
foo
|
|
|
6c1aee8 |
EOF
|
|
|
6c1aee8 |
+
|
|
|
6c1aee8 |
+# Test the case where one ed-style patch modifies several files
|
|
|
6c1aee8 |
+
|
|
|
6c1aee8 |
+cat > ed3.diff <
|
|
|
6c1aee8 |
+--- foo
|
|
|
6c1aee8 |
++++ foo
|
|
|
6c1aee8 |
+1c
|
|
|
6c1aee8 |
+bar
|
|
|
6c1aee8 |
+.
|
|
|
6c1aee8 |
+--- baz
|
|
|
6c1aee8 |
++++ baz
|
|
|
6c1aee8 |
+0a
|
|
|
6c1aee8 |
+baz
|
|
|
6c1aee8 |
+.
|
|
|
6c1aee8 |
+EOF
|
|
|
6c1aee8 |
+
|
|
|
6c1aee8 |
+# Apparently we can't create a file with such a patch, while it works fine
|
|
|
6c1aee8 |
+# when the file name is provided on the command line
|
|
|
6c1aee8 |
+cat > baz <
|
|
|
6c1aee8 |
+EOF
|
|
|
6c1aee8 |
+
|
|
|
6c1aee8 |
+check 'patch -e -i ed3.diff' <
|
|
|
6c1aee8 |
+EOF
|
|
|
6c1aee8 |
+
|
|
|
6c1aee8 |
+check 'cat foo' <
|
|
|
6c1aee8 |
+bar
|
|
|
6c1aee8 |
+EOF
|
|
|
6c1aee8 |
+
|
|
|
6c1aee8 |
+check 'cat baz' <
|
|
|
6c1aee8 |
+baz
|
|
|
6c1aee8 |
+EOF
|