This commit is contained in:
Tim Waugh 2015-01-23 09:54:43 +00:00
parent 805be3927d
commit 5587b741e0
11 changed files with 68 additions and 509 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@ patch-2.6.tar.xz
patch-2.6.1.tar.xz
/patch-2.7.tar.xz
/patch-2.7.1.tar.xz
/patch-2.7.2.tar.xz

View File

@ -1,7 +0,0 @@
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
iEYEABECAAYFAlBl1CwACgkQ9+hy/rlxVNM6+ACgmJmBZhc7jJKR6qmrlGLt7/6a
qT4AoNRERhprm8oQWEJvQfv++kFyYmMS
=0Wdl
-----END PGP SIGNATURE-----

17
patch-2.7.2.tar.xz.sig Normal file
View File

@ -0,0 +1,17 @@
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
iQIcBAABAgAGBQJUvuVFAAoJEMTJJ81dGzbX6mcP/RTbggN+E0KdDpsTRyIJmSM/
Wqql+SYMZlrXNqC9fpflfXodwumnztJcZxIubHfZiiJM1AeWTL3c7qWmlGXz7/og
CFLv6nKQQ26p45FthtCRRlYkTLymoMcVjju+C7WoxheZe6oy5kD6KeDXfQKvy9mc
09EbCt3OlKwztk/toRnk+Zwj9l3GtfhqPCqIO7vmT/KyV1lErWHVGvKw8Ecrb4jg
YcMJ3ttXschvkZWDmJibnBdJOFd5qFWjpOqbcmLkEeDDnKaIQ0YRwOdfDi761aPO
h1XZkt2cbFsAAmGegFFxPOxQjBX9hmJZ9tl/x1ka/iSBBEAljqvLWh11E5ZToUtS
QGD9t7uDFEyVKNpkSkiqsgGh5U4eyOxbsni22ZWtjeHWlIwoamEEp77211/FlROF
V1nZvuF12p+HyRKOl4UV3/EHUlWTXhzbLyRPNeQFBUcXk+KPrk9K2yicQmSDa+qF
Y4zNFE7Cs8AVh18CzzILXj31FS1sNp8BxUq3tEGz5DOrS/McvQvoYS4FWT/SzVOp
q8g3PzgC5G1suA3Lp8DK9okYOttHpU1ZUlldg11Q5FPjoRZVyhdaBRUko3GFxMWs
5/EMvIFNz2X5vUD6Bl+ggWd8yYdTYngBMxB0KRukgaO/sjKffjww83l3knpapimm
02+0Xdc/j2e9gE1xDvMR
=Y3Lt
-----END PGP SIGNATURE-----

View File

@ -1,212 +0,0 @@
diff -up patch-2.7.1/src/pch.c.CVE-2015-1196 patch-2.7.1/src/pch.c
--- patch-2.7.1/src/pch.c.CVE-2015-1196 2012-09-22 18:44:33.000000000 +0100
+++ patch-2.7.1/src/pch.c 2015-01-20 13:29:14.304859557 +0000
@@ -387,29 +387,6 @@ skip_hex_digits (char const *str)
return s == str ? NULL : s;
}
-/* Check if we are in the root of a particular filesystem namespace ("/" on
- UNIX or a particular drive's root on DOS-like systems). */
-static bool
-cwd_is_root (char const *name)
-{
- unsigned int prefix_len = FILE_SYSTEM_PREFIX_LEN (name);
- char root[prefix_len + 2];
- struct stat st;
- dev_t root_dev;
- ino_t root_ino;
-
- memcpy (root, name, prefix_len);
- root[prefix_len] = '/';
- root[prefix_len + 1] = 0;
- if (stat (root, &st))
- return false;
- root_dev = st.st_dev;
- root_ino = st.st_ino;
- if (stat (".", &st))
- return false;
- return root_dev == st.st_dev && root_ino == st.st_ino;
-}
-
static bool
name_is_valid (char const *name)
{
diff -up patch-2.7.1/src/util.c.CVE-2015-1196 patch-2.7.1/src/util.c
--- patch-2.7.1/src/util.c.CVE-2015-1196 2012-09-22 21:09:10.000000000 +0100
+++ patch-2.7.1/src/util.c 2015-01-20 13:29:14.305859561 +0000
@@ -422,6 +422,60 @@ create_backup (char const *to, const str
}
}
+static bool
+symlink_target_is_valid (char const *target, char const *to)
+{
+ bool is_valid;
+
+ if (IS_ABSOLUTE_FILE_NAME (to))
+ is_valid = true;
+ else if (IS_ABSOLUTE_FILE_NAME (target))
+ is_valid = false;
+ else
+ {
+ unsigned int depth = 0;
+ char const *t;
+
+ is_valid = true;
+ t = to;
+ while (*t)
+ {
+ while (*t && ! ISSLASH (*t))
+ t++;
+ if (ISSLASH (*t))
+ {
+ while (ISSLASH (*t))
+ t++;
+ depth++;
+ }
+ }
+
+ t = target;
+ while (*t)
+ {
+ if (*t == '.' && *++t == '.' && (! *++t || ISSLASH (*t)))
+ {
+ if (! depth--)
+ {
+ is_valid = false;
+ break;
+ }
+ }
+ else
+ {
+ while (*t && ! ISSLASH (*t))
+ t++;
+ depth++;
+ }
+ while (ISSLASH (*t))
+ t++;
+ }
+ }
+
+ /* Allow any symlink target if we are in the filesystem root. */
+ return is_valid || cwd_is_root (to);
+}
+
/* Move a file FROM (where *FROM_NEEDS_REMOVAL is nonzero if FROM
needs removal when cleaning up at the end of execution, and where
*FROMST is FROM's status if known),
@@ -465,6 +519,13 @@ move_file (char const *from, bool *from_
read_fatal ();
buffer[size] = 0;
+ if (! symlink_target_is_valid (buffer, to))
+ {
+ fprintf (stderr, "symbolic link target '%s' is invalid\n",
+ buffer);
+ fatal_exit (0);
+ }
+
if (! backup)
{
if (unlink (to) == 0)
@@ -1660,3 +1721,26 @@ int stat_file (char const *filename, str
return xstat (filename, st) == 0 ? 0 : errno;
}
+
+/* Check if we are in the root of a particular filesystem namespace ("/" on
+ UNIX or a particular drive's root on DOS-like systems). */
+bool
+cwd_is_root (char const *name)
+{
+ unsigned int prefix_len = FILE_SYSTEM_PREFIX_LEN (name);
+ char root[prefix_len + 2];
+ struct stat st;
+ dev_t root_dev;
+ ino_t root_ino;
+
+ memcpy (root, name, prefix_len);
+ root[prefix_len] = '/';
+ root[prefix_len + 1] = 0;
+ if (stat (root, &st))
+ return false;
+ root_dev = st.st_dev;
+ root_ino = st.st_ino;
+ if (stat (".", &st))
+ return false;
+ return root_dev == st.st_dev && root_ino == st.st_ino;
+}
diff -up patch-2.7.1/src/util.h.CVE-2015-1196 patch-2.7.1/src/util.h
--- patch-2.7.1/src/util.h.CVE-2015-1196 2012-09-21 21:21:16.000000000 +0100
+++ patch-2.7.1/src/util.h 2015-01-20 13:29:14.306859564 +0000
@@ -69,6 +69,7 @@ enum file_id_type lookup_file_id (struct
void set_queued_output (struct stat const *, bool);
bool has_queued_output (struct stat const *);
int stat_file (char const *, struct stat *);
+bool cwd_is_root (char const *);
enum file_attributes {
FA_TIMES = 1,
diff -up patch-2.7.1/tests/symlinks.CVE-2015-1196 patch-2.7.1/tests/symlinks
--- patch-2.7.1/tests/symlinks.CVE-2015-1196 2012-09-19 02:18:42.000000000 +0100
+++ patch-2.7.1/tests/symlinks 2015-01-20 13:29:14.306859564 +0000
@@ -146,6 +146,59 @@ ncheck 'test ! -L symlink'
# --------------------------------------------------------------
+# Patch should not create symlinks which point outside the working directory.
+
+cat > symlink-target.diff <<EOF
+diff --git a/dir/foo b/dir/foo
+new file mode 120000
+index 0000000..cad2309
+--- /dev/null
++++ b/dir/foo
+@@ -0,0 +1 @@
++../foo
+\ No newline at end of file
+EOF
+
+check 'patch -p1 < symlink-target.diff || echo "Status: $?"' <<EOF
+patching symbolic link dir/foo
+EOF
+
+cat > bad-symlink-target1.diff <<EOF
+diff --git a/bar b/bar
+new file mode 120000
+index 0000000..cad2309
+--- /dev/null
++++ b/bar
+@@ -0,0 +1 @@
++/bar
+\ No newline at end of file
+EOF
+
+check 'patch -p1 < bad-symlink-target1.diff || echo "Status: $?"' <<EOF
+patching symbolic link bar
+symbolic link target '/bar' is invalid
+Status: 2
+EOF
+
+cat > bad-symlink-target2.diff <<EOF
+diff --git a/baz b/baz
+new file mode 120000
+index 0000000..cad2309
+--- /dev/null
++++ b/baz
+@@ -0,0 +1 @@
++../baz
+\ No newline at end of file
+EOF
+
+check 'patch -p1 < bad-symlink-target2.diff || echo "Status: $?"' <<EOF
+patching symbolic link baz
+symbolic link target '../baz' is invalid
+Status: 2
+EOF
+
+# --------------------------------------------------------------
+
# The backup file of a new symlink is an empty regular file.
check 'patch -p1 --backup < create-symlink.diff || echo "Status: $?"' <<EOF

View File

@ -1,20 +0,0 @@
diff -up patch-2.7.1/src/patch.c.args-segfault patch-2.7.1/src/patch.c
--- patch-2.7.1/src/patch.c.args-segfault 2013-06-12 16:48:50.617108731 +0100
+++ patch-2.7.1/src/patch.c 2013-06-12 16:49:06.790181916 +0100
@@ -150,6 +150,8 @@ main (int argc, char **argv)
else if ((version_control = getenv ("VERSION_CONTROL")))
version_control_context = "$VERSION_CONTROL";
+ init_files_to_output ();
+
/* parse switches */
Argc = argc;
Argv = argv;
@@ -164,7 +166,6 @@ main (int argc, char **argv)
init_backup_hash_table ();
init_files_to_delete ();
- init_files_to_output ();
init_output (&outstate);
if (outfile)

View File

@ -1,20 +0,0 @@
diff -up patch-2.7.1/src/patch.c.args patch-2.7.1/src/patch.c
--- patch-2.7.1/src/patch.c.args 2013-04-11 11:30:52.644026499 +0100
+++ patch-2.7.1/src/patch.c 2013-04-11 11:31:54.990246532 +0100
@@ -762,7 +762,7 @@ static char const *const option_help[] =
"",
" -D NAME --ifdef=NAME Make merged if-then-else output using NAME.",
#ifdef ENABLE_MERGE
-" -m --merge Merge using conflict markers instead of creating reject files.",
+" --merge Merge using conflict markers instead of creating reject files.",
#endif
" -E --remove-empty-files Remove output files that are empty after patching.",
"",
@@ -801,6 +801,7 @@ static char const *const option_help[] =
" --binary Read and write data in binary mode.",
" --read-only=BEHAVIOR How to handle read-only input files: 'ignore' that they",
" are read-only, 'warn' (default), or 'fail'.",
+" -x NUM --debug=NUM Set internal debugging flags.",
"",
" -v --version Output version info.",
" --help Output this help.",

View File

@ -1,125 +0,0 @@
diff -up patch-2.7.1/src/common.h.lineno-overflow patch-2.7.1/src/common.h
--- patch-2.7.1/src/common.h.lineno-overflow 2012-09-28 15:00:04.000000000 +0100
+++ patch-2.7.1/src/common.h 2015-01-20 14:47:37.262280623 +0000
@@ -39,6 +39,7 @@
#elif HAVE_STDINT_H
# include <stdint.h>
#endif
+#include <intprops.h>
#include <ctype.h>
/* CTYPE_DOMAIN (C) is nonzero if the unsigned char C can safely be given
@@ -68,6 +69,9 @@
typedef off_t lin; /* must be signed */
+#define LINENUM_MIN TYPE_MINIMUM (lin)
+#define LINENUM_MAX TYPE_MAXIMUM (lin)
+
/* globals */
XTERN char *buf; /* general purpose buffer */
diff -up patch-2.7.1/src/pch.c.lineno-overflow patch-2.7.1/src/pch.c
--- patch-2.7.1/src/pch.c.lineno-overflow 2015-01-20 14:46:49.533109967 +0000
+++ patch-2.7.1/src/pch.c 2015-01-20 14:47:37.264280630 +0000
@@ -1294,6 +1294,8 @@ another_hunk (enum diff difftype, bool r
s++;
scan_linenum (s, &p_ptrn_lines);
p_ptrn_lines += 1 - p_first;
+ if (p_ptrn_lines < 0)
+ malformed ();
}
else if (p_first)
p_ptrn_lines = 1;
@@ -1301,6 +1303,9 @@ another_hunk (enum diff difftype, bool r
p_ptrn_lines = 0;
p_first = 1;
}
+ if (p_first >= LINENUM_MAX - p_ptrn_lines ||
+ p_ptrn_lines >= LINENUM_MAX - 6)
+ malformed ();
p_max = p_ptrn_lines + 6; /* we need this much at least */
while (p_max + 1 >= hunkmax)
if (! grow_hunkmax ())
@@ -1370,6 +1375,8 @@ another_hunk (enum diff difftype, bool r
while (! ISDIGIT (*s));
scan_linenum (s, &p_repl_lines);
p_repl_lines += 1 - p_newfirst;
+ if (p_repl_lines < 0)
+ malformed ();
}
else if (p_newfirst)
p_repl_lines = 1;
@@ -1378,6 +1385,9 @@ another_hunk (enum diff difftype, bool r
p_repl_lines = 0;
p_newfirst = 1;
}
+ if (p_newfirst >= LINENUM_MAX - p_repl_lines ||
+ p_repl_lines >= LINENUM_MAX - p_end)
+ malformed ();
p_max = p_repl_lines + p_end;
while (p_max + 1 >= hunkmax)
if (! grow_hunkmax ())
@@ -1617,6 +1627,8 @@ another_hunk (enum diff difftype, bool r
s = scan_linenum (s + 1, &p_ptrn_lines);
else
p_ptrn_lines = 1;
+ if (p_first >= LINENUM_MAX - p_ptrn_lines)
+ malformed ();
if (*s == ' ') s++;
if (*s != '+')
malformed ();
@@ -1625,6 +1637,8 @@ another_hunk (enum diff difftype, bool r
s = scan_linenum (s + 1, &p_repl_lines);
else
p_repl_lines = 1;
+ if (p_newfirst >= LINENUM_MAX - p_repl_lines)
+ malformed ();
if (*s == ' ') s++;
if (*s++ != '@')
malformed ();
@@ -1640,6 +1654,8 @@ another_hunk (enum diff difftype, bool r
p_first++; /* do append rather than insert */
if (!p_repl_lines)
p_newfirst++;
+ if (p_ptrn_lines >= LINENUM_MAX - (p_repl_lines + 1))
+ malformed ();
p_max = p_ptrn_lines + p_repl_lines + 1;
while (p_max + 1 >= hunkmax)
if (! grow_hunkmax ())
@@ -1776,6 +1792,8 @@ another_hunk (enum diff difftype, bool r
}
else
p_ptrn_lines = (*s != 'a');
+ if (p_first >= LINENUM_MAX - p_ptrn_lines)
+ malformed ();
hunk_type = *s;
if (hunk_type == 'a')
p_first++; /* do append rather than insert */
@@ -1784,17 +1802,23 @@ another_hunk (enum diff difftype, bool r
scan_linenum (s + 1, &max);
else
max = min;
+ if (min > max || max - min == LINENUM_MAX)
+ malformed ();
if (hunk_type == 'd')
min++;
- p_end = p_ptrn_lines + 1 + max - min + 1;
+ p_newfirst = min;
+ p_repl_lines = max - min + 1;
+ if (p_newfirst >= LINENUM_MAX - p_repl_lines)
+ malformed ();
+ if (p_ptrn_lines >= LINENUM_MAX - (p_repl_lines + 1))
+ malformed ();
+ p_end = p_ptrn_lines + p_repl_lines + 1;
while (p_end + 1 >= hunkmax)
if (! grow_hunkmax ())
{
p_end = -1;
return -1;
}
- p_newfirst = min;
- p_repl_lines = max - min + 1;
sprintf (buf, "*** %s,%s\n",
format_linenum (numbuf0, p_first),
format_linenum (numbuf1, p_first + p_ptrn_lines - 1));

View File

@ -1,57 +0,0 @@
diff -up patch-2.7.1/src/patch.c.remove-empty-dir patch-2.7.1/src/patch.c
--- patch-2.7.1/src/patch.c.remove-empty-dir 2012-10-18 17:57:41.708586721 +0100
+++ patch-2.7.1/src/patch.c 2013-03-11 11:35:54.607901400 +0000
@@ -646,8 +646,8 @@ main (int argc, char **argv)
if (outstate.ofp && (ferror (outstate.ofp) || fclose (outstate.ofp) != 0))
write_fatal ();
output_files (NULL);
- delete_files ();
cleanup ();
+ delete_files ();
if (somefailed)
exit (1);
return 0;
diff -up patch-2.7.1/tests/Makefile.am.remove-empty-dir patch-2.7.1/tests/Makefile.am
--- patch-2.7.1/tests/Makefile.am.remove-empty-dir 2012-09-14 10:15:22.000000000 +0100
+++ patch-2.7.1/tests/Makefile.am 2013-03-11 11:35:54.619901466 +0000
@@ -49,6 +49,7 @@ TESTS = \
reject-format \
remember-backup-files \
remember-reject-files \
+ remove-directories \
symlinks \
unmodified-files
diff -up patch-2.7.1/tests/remove-directories.remove-empty-dir patch-2.7.1/tests/remove-directories
--- patch-2.7.1/tests/remove-directories.remove-empty-dir 2013-03-11 11:35:54.619901466 +0000
+++ patch-2.7.1/tests/remove-directories 2013-03-11 11:35:54.619901466 +0000
@@ -0,0 +1,29 @@
+# Copyright (C) 2013 Free Software Foundation, Inc.
+#
+# Copying and distribution of this file, with or without modification,
+# in any medium, are permitted without royalty provided the copyright
+# notice and this notice are preserved.
+
+. $srcdir/test-lib.sh
+
+require_cat
+use_local_patch
+use_tmpdir
+
+# ==============================================================
+# Remove empty parent diectories when removing a file
+
+mkdir dir
+echo foobar > dir/file
+cat > apatch <<EOF
+--- dir/file
++++ /dev/null
+@@ -1 +0,0 @@
+-foobar
+EOF
+
+check 'patch -p0 -E < apatch' <<EOF
+patching file dir/file
+EOF
+
+ncheck '! test -e dir'

View File

@ -1,6 +1,6 @@
diff -up patch-2.7.1/src/common.h.selinux patch-2.7.1/src/common.h
--- patch-2.7.1/src/common.h.selinux 2012-09-28 15:00:04.000000000 +0100
+++ patch-2.7.1/src/common.h 2015-01-20 13:29:30.388915881 +0000
diff -up patch-2.7.2/src/common.h.selinux patch-2.7.2/src/common.h
--- patch-2.7.2/src/common.h.selinux 2015-01-19 17:24:29.000000000 +0000
+++ patch-2.7.2/src/common.h 2015-01-21 15:17:16.267750752 +0000
@@ -30,6 +30,8 @@
#include <sys/types.h>
#include <time.h>
@ -10,7 +10,7 @@ diff -up patch-2.7.1/src/common.h.selinux patch-2.7.1/src/common.h
#include <sys/stat.h>
#include <limits.h>
@@ -80,6 +82,7 @@ XTERN char *outfile;
@@ -84,6 +86,7 @@ XTERN char *outfile;
XTERN int inerrno;
XTERN int invc;
XTERN struct stat instat;
@ -18,10 +18,10 @@ diff -up patch-2.7.1/src/common.h.selinux patch-2.7.1/src/common.h
XTERN bool dry_run;
XTERN bool posixly_correct;
diff -up patch-2.7.1/src/inp.c.selinux patch-2.7.1/src/inp.c
--- patch-2.7.1/src/inp.c.selinux 2012-09-19 02:07:31.000000000 +0100
+++ patch-2.7.1/src/inp.c 2015-01-20 13:29:30.388915881 +0000
@@ -138,7 +138,7 @@ get_input_file (char const *filename, ch
diff -up patch-2.7.2/src/inp.c.selinux patch-2.7.2/src/inp.c
--- patch-2.7.2/src/inp.c.selinux 2014-11-26 13:17:55.000000000 +0000
+++ patch-2.7.2/src/inp.c 2015-01-21 15:17:16.277750792 +0000
@@ -144,7 +144,7 @@ get_input_file (char const *filename, ch
char *getbuf;
if (inerrno == -1)
@ -30,7 +30,7 @@ diff -up patch-2.7.1/src/inp.c.selinux patch-2.7.1/src/inp.c
/* Perhaps look for RCS or SCCS versions. */
if (S_ISREG (file_type)
@@ -183,7 +183,7 @@ get_input_file (char const *filename, ch
@@ -189,7 +189,7 @@ get_input_file (char const *filename, ch
}
if (cs && version_get (filename, cs, ! inerrno, elsewhere, getbuf,
@ -39,7 +39,7 @@ diff -up patch-2.7.1/src/inp.c.selinux patch-2.7.1/src/inp.c
inerrno = 0;
free (getbuf);
@@ -194,6 +194,7 @@ get_input_file (char const *filename, ch
@@ -200,6 +200,7 @@ get_input_file (char const *filename, ch
{
instat.st_mode = S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH;
instat.st_size = 0;
@ -47,9 +47,9 @@ diff -up patch-2.7.1/src/inp.c.selinux patch-2.7.1/src/inp.c
}
else if (! ((S_ISREG (file_type) || S_ISLNK (file_type))
&& (file_type & S_IFMT) == (instat.st_mode & S_IFMT)))
diff -up patch-2.7.1/src/Makefile.am.selinux patch-2.7.1/src/Makefile.am
--- patch-2.7.1/src/Makefile.am.selinux 2012-09-14 10:15:41.000000000 +0100
+++ patch-2.7.1/src/Makefile.am 2015-01-20 13:29:30.388915881 +0000
diff -up patch-2.7.2/src/Makefile.am.selinux patch-2.7.2/src/Makefile.am
--- patch-2.7.2/src/Makefile.am.selinux 2014-11-26 13:17:55.000000000 +0000
+++ patch-2.7.2/src/Makefile.am 2015-01-21 15:17:16.278750796 +0000
@@ -34,7 +34,7 @@ patch_SOURCES = \
AM_CPPFLAGS = -I$(top_builddir)/lib -I$(top_srcdir)/lib
@ -59,10 +59,10 @@ diff -up patch-2.7.1/src/Makefile.am.selinux patch-2.7.1/src/Makefile.am
if ENABLE_MERGE
patch_SOURCES += merge.c
diff -up patch-2.7.1/src/Makefile.in.selinux patch-2.7.1/src/Makefile.in
--- patch-2.7.1/src/Makefile.in.selinux 2012-09-28 17:41:31.000000000 +0100
+++ patch-2.7.1/src/Makefile.in 2015-01-20 13:29:30.389915884 +0000
@@ -981,7 +981,7 @@ patch_SOURCES = bestmatch.h common.h inp
diff -up patch-2.7.2/src/Makefile.in.selinux patch-2.7.2/src/Makefile.in
--- patch-2.7.2/src/Makefile.in.selinux 2015-01-19 19:36:16.000000000 +0000
+++ patch-2.7.2/src/Makefile.in 2015-01-21 15:17:16.278750796 +0000
@@ -1047,7 +1047,7 @@ patch_SOURCES = bestmatch.h common.h inp
AM_CPPFLAGS = -I$(top_builddir)/lib -I$(top_srcdir)/lib \
$(am__append_2)
patch_LDADD = $(LDADD) $(top_builddir)/lib/libpatch.a $(LIB_CLOCK_GETTIME) \
@ -71,9 +71,9 @@ diff -up patch-2.7.1/src/Makefile.in.selinux patch-2.7.1/src/Makefile.in
all: all-am
diff -up patch-2.7.1/src/patch.c.selinux patch-2.7.1/src/patch.c
--- patch-2.7.1/src/patch.c.selinux 2015-01-20 13:29:30.383915863 +0000
+++ patch-2.7.1/src/patch.c 2015-01-20 13:29:30.389915884 +0000
diff -up patch-2.7.2/src/patch.c.selinux patch-2.7.2/src/patch.c
--- patch-2.7.2/src/patch.c.selinux 2015-01-20 09:11:48.000000000 +0000
+++ patch-2.7.2/src/patch.c 2015-01-21 15:17:16.278750796 +0000
@@ -257,19 +257,19 @@ main (int argc, char **argv)
if (! strcmp (inname, outname))
{
@ -115,7 +115,7 @@ diff -up patch-2.7.1/src/patch.c.selinux patch-2.7.1/src/patch.c
if (olderrno && olderrno != ENOENT)
write_fatal ();
if (! olderrno && lookup_file_id (&oldst) == CREATED)
@@ -1751,7 +1751,7 @@ delete_file_later (const char *name, con
@@ -1754,7 +1754,7 @@ delete_file_later (const char *name, con
if (! st)
{
@ -124,9 +124,9 @@ diff -up patch-2.7.1/src/patch.c.selinux patch-2.7.1/src/patch.c
pfatal ("Can't get file attributes of %s %s", "file", name);
st = &st_tmp;
}
diff -up patch-2.7.1/src/pch.c.selinux patch-2.7.1/src/pch.c
--- patch-2.7.1/src/pch.c.selinux 2015-01-20 13:29:30.385915870 +0000
+++ patch-2.7.1/src/pch.c 2015-01-20 13:29:30.389915884 +0000
diff -up patch-2.7.2/src/pch.c.selinux patch-2.7.2/src/pch.c
--- patch-2.7.2/src/pch.c.selinux 2015-01-20 11:43:07.000000000 +0000
+++ patch-2.7.2/src/pch.c 2015-01-21 15:18:00.130926862 +0000
@@ -1,6 +1,6 @@
/* reading patches */
@ -135,16 +135,16 @@ diff -up patch-2.7.1/src/pch.c.selinux patch-2.7.1/src/pch.c
Copyright (C) 1990-1993, 1997-2003, 2006, 2009-2012 Free Software
Foundation, Inc.
@@ -293,7 +293,7 @@ there_is_another_patch (bool need_header
@@ -292,7 +292,7 @@ there_is_another_patch (bool need_header
if (t > buf + 1 && *(t - 1) == '\n')
{
inname = savebuf (buf, t - buf);
inname[t - buf - 1] = 0;
inname = xmemdup0 (buf, t - buf - 1);
- inerrno = stat_file (inname, &instat);
+ inerrno = stat_file (inname, &instat, &incontext);
if (inerrno)
{
perror (inname);
@@ -445,6 +445,7 @@ intuit_diff_type (bool need_header, mode
@@ -444,6 +444,7 @@ intuit_diff_type (bool need_header, mode
bool extended_headers = false;
enum nametype i;
struct stat st[3];
@ -152,7 +152,7 @@ diff -up patch-2.7.1/src/pch.c.selinux patch-2.7.1/src/pch.c
int stat_errno[3];
int version_controlled[3];
enum diff retval;
@@ -484,6 +485,7 @@ intuit_diff_type (bool need_header, mode
@@ -483,6 +484,7 @@ intuit_diff_type (bool need_header, mode
version_controlled[OLD] = -1;
version_controlled[NEW] = -1;
version_controlled[INDEX] = -1;
@ -160,7 +160,7 @@ diff -up patch-2.7.1/src/pch.c.selinux patch-2.7.1/src/pch.c
p_rfc934_nesting = 0;
p_timestamp[OLD].tv_sec = p_timestamp[NEW].tv_sec = -1;
p_says_nonexistent[OLD] = p_says_nonexistent[NEW] = 0;
@@ -891,7 +893,7 @@ intuit_diff_type (bool need_header, mode
@@ -890,7 +892,7 @@ intuit_diff_type (bool need_header, mode
}
else
{
@ -169,7 +169,7 @@ diff -up patch-2.7.1/src/pch.c.selinux patch-2.7.1/src/pch.c
if (! stat_errno[i])
{
if (lookup_file_id (&st[i]) == DELETE_LATER)
@@ -930,7 +932,7 @@ intuit_diff_type (bool need_header, mode
@@ -929,7 +931,7 @@ intuit_diff_type (bool need_header, mode
if (cs)
{
if (version_get (p_name[i], cs, false, readonly,
@ -178,7 +178,7 @@ diff -up patch-2.7.1/src/pch.c.selinux patch-2.7.1/src/pch.c
stat_errno[i] = 0;
else
version_controlled[i] = 0;
@@ -983,7 +985,7 @@ intuit_diff_type (bool need_header, mode
@@ -982,7 +984,7 @@ intuit_diff_type (bool need_header, mode
{
if (inname)
{
@ -187,7 +187,7 @@ diff -up patch-2.7.1/src/pch.c.selinux patch-2.7.1/src/pch.c
if (inerrno || (instat.st_mode & S_IFMT) == file_type)
maybe_reverse (inname, inerrno, inerrno || instat.st_size == 0);
}
@@ -996,8 +998,14 @@ intuit_diff_type (bool need_header, mode
@@ -995,8 +997,14 @@ intuit_diff_type (bool need_header, mode
inerrno = stat_errno[i];
invc = version_controlled[i];
instat = st[i];
@ -202,10 +202,10 @@ diff -up patch-2.7.1/src/pch.c.selinux patch-2.7.1/src/pch.c
return retval;
}
diff -up patch-2.7.1/src/util.c.selinux patch-2.7.1/src/util.c
--- patch-2.7.1/src/util.c.selinux 2015-01-20 13:29:30.386915874 +0000
+++ patch-2.7.1/src/util.c 2015-01-20 13:29:30.390915888 +0000
@@ -294,6 +294,19 @@ set_file_attributes (char const *to, enu
diff -up patch-2.7.2/src/util.c.selinux patch-2.7.2/src/util.c
--- patch-2.7.2/src/util.c.selinux 2015-01-20 09:08:38.000000000 +0000
+++ patch-2.7.2/src/util.c 2015-01-21 15:17:16.279750800 +0000
@@ -295,6 +295,19 @@ set_file_attributes (char const *to, enu
S_ISLNK (mode) ? "symbolic link" : "file",
quotearg (to));
}
@ -225,7 +225,7 @@ diff -up patch-2.7.1/src/util.c.selinux patch-2.7.1/src/util.c
}
static void
@@ -494,7 +507,7 @@ move_file (char const *from, bool *from_
@@ -495,7 +508,7 @@ move_file (char const *from, bool *from_
struct stat to_st;
int to_errno;
@ -234,7 +234,7 @@ diff -up patch-2.7.1/src/util.c.selinux patch-2.7.1/src/util.c
if (backup)
create_backup (to, to_errno ? NULL : &to_st, false);
if (! to_errno)
@@ -871,7 +884,8 @@ version_controller (char const *filename
@@ -872,7 +885,8 @@ version_controller (char const *filename
Return true if successful. */
bool
version_get (char const *filename, char const *cs, bool exists, bool readonly,
@ -244,7 +244,7 @@ diff -up patch-2.7.1/src/util.c.selinux patch-2.7.1/src/util.c
{
if (patch_get < 0)
{
@@ -896,6 +910,13 @@ version_get (char const *filename, char
@@ -897,6 +911,13 @@ version_get (char const *filename, char
fatal ("Can't get file %s from %s", quotearg (filename), cs);
if (stat (filename, filestat) != 0)
pfatal ("%s", quotearg (filename));
@ -258,7 +258,7 @@ diff -up patch-2.7.1/src/util.c.selinux patch-2.7.1/src/util.c
}
return 1;
@@ -1714,12 +1735,28 @@ make_tempfile (char const **name, char l
@@ -1712,12 +1733,28 @@ make_tempfile (char const **name, char l
}
}
@ -289,9 +289,9 @@ diff -up patch-2.7.1/src/util.c.selinux patch-2.7.1/src/util.c
}
/* Check if we are in the root of a particular filesystem namespace ("/" on
diff -up patch-2.7.1/src/util.h.selinux patch-2.7.1/src/util.h
--- patch-2.7.1/src/util.h.selinux 2015-01-20 13:29:30.386915874 +0000
+++ patch-2.7.1/src/util.h 2015-01-20 13:30:14.653081617 +0000
diff -up patch-2.7.2/src/util.h.selinux patch-2.7.2/src/util.h
--- patch-2.7.2/src/util.h.selinux 2015-01-20 09:07:24.000000000 +0000
+++ patch-2.7.2/src/util.h 2015-01-21 15:17:16.280750804 +0000
@@ -45,7 +45,7 @@ char *parse_name (char const *, int, cha
char *savebuf (char const *, size_t);
char *savestr (char const *);

View File

@ -1,16 +1,11 @@
Summary: Utility for modifying/upgrading files
Name: patch
Version: 2.7.1
Release: 12%{?dist}
Version: 2.7.2
Release: 1%{?dist}
License: GPLv3+
URL: http://www.gnu.org/software/patch/patch.html
Group: Development/Tools
Source: ftp://ftp.gnu.org/gnu/patch/patch-%{version}.tar.xz
Patch1: patch-remove-empty-dir.patch
Patch2: patch-args.patch
Patch3: patch-args-segfault.patch
Patch4: patch-CVE-2015-1196.patch
Patch5: patch-lineno-overflow.patch
Patch100: patch-selinux.patch
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@ -31,22 +26,6 @@ applications.
%prep
%setup -q
# Upstream patch to fix removal of empty directories (bug #919489).
%patch1 -p1 -b .remove-empty-dir
# Don't document unsupported -m option; document -x option (bug #948972).
%patch2 -p1 -b .args
# Don't segfault when given bad arguments (bug #972330).
%patch3 -p1 -b .args-segfault
# Apply upstream patch to fix directory traversal via symlinks
# (bug #1182157, CVE-2015-1196).
%patch4 -p1 -b .CVE-2015-1196
# Apply upstream patch to fix line numbering integer overflow.
%patch5 -p1 -b .lineno-overflow
# SELinux support.
%patch100 -p1 -b .selinux
@ -75,6 +54,9 @@ rm -rf $RPM_BUILD_ROOT
%{_mandir}/*/*
%changelog
* Fri Jan 23 2015 Tim Waugh <twaugh@redhat.com> - 2.7.2-1
- 2.7.2.
* Tue Jan 20 2015 Tim Waugh <twaugh@redhat.com> - 2.7.1-12
- Apply upstream patch to fix line numbering integer overflow.

View File

@ -1 +1 @@
e9ae5393426d3ad783a300a338c09b72 patch-2.7.1.tar.xz
0b0217d45d3d45d3f07d6b241abbeb2a patch-2.7.2.tar.xz