From 274dc2d261d66b252d9b8d2686f453c795a1e644 Mon Sep 17 00:00:00 2001 From: Tim Waugh Date: Oct 18 2012 16:24:44 +0000 Subject: 2.7. No longer need sigsegv, get-arg, CVE-2010-4651, backup-if-mismatch or coverity-leak patches. --- diff --git a/.gitignore b/.gitignore index 1b77c72..d606fe7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ patch-2.5.4.tar.gz patch-2.6.tar.xz patch-2.6.1.tar.xz +/patch-2.7.tar.xz diff --git a/patch-2.5.4-sigsegv.patch b/patch-2.5.4-sigsegv.patch deleted file mode 100644 index c018153..0000000 --- a/patch-2.5.4-sigsegv.patch +++ /dev/null @@ -1,42 +0,0 @@ -diff -up patch-2.6/src/inp.c.sigsegv patch-2.6/src/inp.c ---- patch-2.6/src/inp.c.sigsegv 2009-11-02 19:09:57.000000000 +0000 -+++ patch-2.6/src/inp.c 2009-11-16 09:31:52.305022200 +0000 -@@ -77,6 +77,14 @@ re_input (void) - } - } - -+void -+reset_scan_input_vars() -+{ -+ using_plan_a = 1; -+ i_buffer = NULL; -+ i_ptr = NULL; -+} -+ - /* Construct the line index, somehow or other. */ - - void -diff -up patch-2.6/src/inp.h.sigsegv patch-2.6/src/inp.h ---- patch-2.6/src/inp.h.sigsegv 2009-11-02 19:09:57.000000000 +0000 -+++ patch-2.6/src/inp.h 2009-11-16 09:32:24.440021838 +0000 -@@ -24,4 +24,5 @@ XTERN LINENUM input_lines; /* how long - char const *ifetch (LINENUM, bool, size_t *); - void get_input_file (char const *, char const *); - void re_input (void); -+void reset_scan_input_vars (void); - void scan_input (char *); -diff -up patch-2.6/src/patch.c.sigsegv patch-2.6/src/patch.c ---- patch-2.6/src/patch.c.sigsegv 2009-11-02 19:09:57.000000000 +0000 -+++ patch-2.6/src/patch.c 2009-11-16 09:31:52.306021801 +0000 -@@ -210,7 +210,10 @@ main (int argc, char **argv) - - /* find out where all the lines are */ - if (!skip_rest_of_patch) -- scan_input (inname); -+ scan_input (inname); -+ else -+ reset_scan_input_vars (); -+ - - /* from here on, open no standard i/o files, because malloc */ - /* might misfire and we can't catch it easily */ diff --git a/patch-2.6.1.tar.xz.sig b/patch-2.6.1.tar.xz.sig deleted file mode 100644 index fee87dc..0000000 --- a/patch-2.6.1.tar.xz.sig +++ /dev/null @@ -1,7 +0,0 @@ ------BEGIN PGP SIGNATURE----- -Version: GnuPG v2.0.12 (GNU/Linux) - -iEYEABECAAYFAks7frsACgkQ9+hy/rlxVNONpwCgr0yqYFoW0Q1USWGBcA8dGNEn -XUMAn1RB5jT/EoiNi9ZrjawqxAT83JzB -=/8JO ------END PGP SIGNATURE----- diff --git a/patch-2.7.tar.xz.sig b/patch-2.7.tar.xz.sig new file mode 100644 index 0000000..fdcc64b --- /dev/null +++ b/patch-2.7.tar.xz.sig @@ -0,0 +1,7 @@ +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.12 (GNU/Linux) + +iEYEABECAAYFAlBQWaAACgkQ9+hy/rlxVNPdqwCePxf2mZmHhEw2dfdGp/Fq0uuB +/3oAoLlxmZxIodFqnT+3h8bna7+oEAWL +=4Gbj +-----END PGP SIGNATURE----- diff --git a/patch-backup-if-mismatch.patch b/patch-backup-if-mismatch.patch deleted file mode 100644 index 0ad0986..0000000 --- a/patch-backup-if-mismatch.patch +++ /dev/null @@ -1,31 +0,0 @@ -diff -up patch-2.6.1/src/patch.c.backup-if-mismatch patch-2.6.1/src/patch.c ---- patch-2.6.1/src/patch.c.backup-if-mismatch 2011-02-16 16:43:54.575850844 +0000 -+++ patch-2.6.1/src/patch.c 2011-02-16 16:44:56.907995789 +0000 -@@ -106,6 +106,7 @@ main (int argc, char **argv) - char numbuf[LINENUM_LENGTH_BOUND + 1]; - bool written_to_rejname = false; - bool apply_empty_patch = false; -+ bool posixly_correct_set; - - exit_failure = 2; - program_name = argv[0]; -@@ -125,7 +126,7 @@ main (int argc, char **argv) - i < 0 ? shell_quoting_style : (enum quoting_style) i); - } - -- posixly_correct = getenv ("POSIXLY_CORRECT") != 0; -+ posixly_correct_set = posixly_correct = getenv ("POSIXLY_CORRECT") != 0; - backup_if_mismatch = ! posixly_correct; - patch_get = ((val = getenv ("PATCH_GET")) - ? numeric_string (val, true, "PATCH_GET value") -@@ -151,6 +152,10 @@ main (int argc, char **argv) - Argv = argv; - get_some_switches(); - -+ /* Let --posix cause --no-backup-if-mismatch. */ -+ if (! posixly_correct_set && posixly_correct && backup_if_mismatch) -+ backup_if_mismatch = false; -+ - if (make_backups | backup_if_mismatch) - backup_type = get_version (version_control_context, version_control); - diff --git a/patch-coverity-leak.patch b/patch-coverity-leak.patch deleted file mode 100644 index 040bb79..0000000 --- a/patch-coverity-leak.patch +++ /dev/null @@ -1,15 +0,0 @@ -diff -up patch-2.6.1/gl/lib/hash.c.coverity-leak patch-2.6.1/gl/lib/hash.c ---- patch-2.6.1/gl/lib/hash.c.coverity-leak 2009-11-02 19:09:57.000000000 +0000 -+++ patch-2.6.1/gl/lib/hash.c 2011-05-16 15:13:49.231998981 +0100 -@@ -857,7 +857,10 @@ hash_rehash (Hash_table *table, size_t c - struct hash_entry *new_entry = allocate_entry (new_table); - - if (new_entry == NULL) -- return false; -+ { -+ free (new_table); -+ return false; -+ } - - new_entry->data = data; - new_entry->next = new_bucket->next; diff --git a/patch-get-arg.patch b/patch-get-arg.patch deleted file mode 100644 index 45f3bc8..0000000 --- a/patch-get-arg.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff -up patch-2.6.1/src/patch.c.get-arg patch-2.6.1/src/patch.c ---- patch-2.6.1/src/patch.c.get-arg 2010-07-27 18:05:26.217150510 +0100 -+++ patch-2.6.1/src/patch.c 2010-07-27 18:05:47.464150892 +0100 -@@ -558,7 +558,7 @@ static struct option const longopts[] = - {"remove-empty-files", no_argument, NULL, 'E'}, - {"force", no_argument, NULL, 'f'}, - {"fuzz", required_argument, NULL, 'F'}, -- {"get", no_argument, NULL, 'g'}, -+ {"get", required_argument, NULL, 'g'}, - {"input", required_argument, NULL, 'i'}, - {"ignore-whitespace", no_argument, NULL, 'l'}, - #ifdef ENABLE_MERGE diff --git a/patch-selinux.patch b/patch-selinux.patch index b9891c5..519dcbb 100644 --- a/patch-selinux.patch +++ b/patch-selinux.patch @@ -1,28 +1,16 @@ -diff -up patch-2.6.1/Makefile.in.selinux patch-2.6.1/Makefile.in ---- patch-2.6.1/Makefile.in.selinux 2011-02-08 11:29:34.590271489 +0000 -+++ patch-2.6.1/Makefile.in 2011-02-08 11:29:34.602271607 +0000 -@@ -40,7 +40,7 @@ EXEEXT = @EXEEXT@ - LDFLAGS = @LDFLAGS@ - LIBOBJDIR = gl/lib/ - LIBOBJS = @LIBOBJS@ ${LIBOBJDIR}full-write$U.o --LIBS = @LIBS@ -+LIBS = @LIBS@ -lselinux - OBJEXT = @OBJEXT@ - PACKAGE_NAME = @PACKAGE_NAME@ - PACKAGE_VERSION = @PACKAGE_VERSION@ -diff -up patch-2.6.1/src/common.h.selinux patch-2.6.1/src/common.h ---- patch-2.6.1/src/common.h.selinux 2009-12-30 12:56:30.000000000 +0000 -+++ patch-2.6.1/src/common.h 2011-02-08 11:29:34.602271607 +0000 -@@ -32,6 +32,8 @@ +diff -up patch-2.7/src/common.h.selinux patch-2.7/src/common.h +--- patch-2.7/src/common.h.selinux 2012-04-17 21:13:36.000000000 +0100 ++++ patch-2.7/src/common.h 2012-10-18 17:04:21.215420195 +0100 +@@ -30,6 +30,8 @@ #include #include +#include + #include - #if ! defined S_ISDIR && defined S_IFDIR - # define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) -@@ -118,6 +120,7 @@ XTERN char *outfile; + + #include +@@ -80,6 +82,7 @@ XTERN char *outfile; XTERN int inerrno; XTERN int invc; XTERN struct stat instat; @@ -30,31 +18,34 @@ diff -up patch-2.6.1/src/common.h.selinux patch-2.6.1/src/common.h XTERN bool dry_run; XTERN bool posixly_correct; -diff -up patch-2.6.1/src/inp.c.selinux patch-2.6.1/src/inp.c ---- patch-2.6.1/src/inp.c.selinux 2011-02-08 11:29:34.576271352 +0000 -+++ patch-2.6.1/src/inp.c 2011-02-08 11:29:34.604271627 +0000 -@@ -152,8 +152,18 @@ get_input_file (char const *filename, ch - char *diffbuf; +diff -up patch-2.7/src/inp.c.selinux patch-2.7/src/inp.c +--- patch-2.7/src/inp.c.selinux 2012-08-07 20:46:33.000000000 +0100 ++++ patch-2.7/src/inp.c 2012-10-18 17:18:31.335799300 +0100 +@@ -138,7 +138,22 @@ get_input_file (char const *filename, ch char *getbuf; -- if (inerrno == -1) -- inerrno = stat (filename, &instat) == 0 ? 0 : errno; -+ inerrno = stat (filename, &instat) == 0 ? 0 : errno; -+ if (inerrno == 0) + if (inerrno == -1) +- inerrno = lstat (filename, &instat) == 0 ? 0 : errno; + { -+ inerrno = getfilecon (inname, &incontext) == -1 ? errno : 0; -+ if (inerrno == ENODATA || inerrno == ENOTSUP) -+ { -+ inerrno = 0; -+ incontext = NULL; -+ } ++ inerrno = lstat (filename, &instat) == 0 ? 0 : errno; ++ if (inerrno == 0) ++ { ++ inerrno = getfilecon (inname, &incontext) == -1 ? errno : 0; ++ if (inerrno == ENODATA || inerrno == ENOTSUP) ++ { ++ inerrno = 0; ++ incontext = NULL; ++ } ++ } ++ else ++ incontext = NULL; + } + else + incontext = NULL; /* Perhaps look for RCS or SCCS versions. */ - if (patch_get -@@ -197,7 +207,7 @@ get_input_file (char const *filename, ch + if (S_ISREG (mode) +@@ -183,7 +198,7 @@ get_input_file (char const *filename, ch } if (cs && version_get (filename, cs, ! inerrno, elsewhere, getbuf, @@ -63,49 +54,60 @@ diff -up patch-2.6.1/src/inp.c.selinux patch-2.6.1/src/inp.c inerrno = 0; free (getbuf); -@@ -209,6 +219,7 @@ get_input_file (char const *filename, ch +@@ -194,6 +209,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; + incontext = NULL; } - else if (! S_ISREG (instat.st_mode)) - fatal ("File %s is not a regular file -- can't patch", -diff -up patch-2.6.1/src/patch.c.selinux patch-2.6.1/src/patch.c ---- patch-2.6.1/src/patch.c.selinux 2011-02-08 11:29:34.586271450 +0000 -+++ patch-2.6.1/src/patch.c 2011-02-08 11:29:34.606271646 +0000 -@@ -421,6 +421,21 @@ main (int argc, char **argv) - /* Fails if we are not in group instat.st_gid. */ - chown (outname, -1, instat.st_gid); - } -+ -+ if (! inerrno && incontext) -+ { -+ security_context_t outcontext; -+ if (getfilecon (outname, &outcontext) != -1 && -+ outcontext && -+ strcmp(outcontext, incontext) && -+ setfilecon (outname, incontext) != 0) -+ { -+ if (errno != ENOTSUP && errno != EPERM) -+ pfatal ("Can't set security context " -+ "on file %s", quotearg (outname)); -+ } -+ } -+ - /* FIXME: There may be other attributes to preserve. */ + else if (! ((S_ISREG (mode) || S_ISLNK (mode)) + && (mode & S_IFMT) == (instat.st_mode & S_IFMT))) +diff -up patch-2.7/src/Makefile.am.selinux patch-2.7/src/Makefile.am +--- patch-2.7/src/Makefile.am.selinux 2012-04-17 08:59:41.000000000 +0100 ++++ patch-2.7/src/Makefile.am 2012-10-18 17:04:21.216420199 +0100 +@@ -34,7 +34,7 @@ patch_SOURCES = \ + + AM_CPPFLAGS = -I$(top_builddir)/lib -I$(top_srcdir)/lib + patch_LDADD = $(LDADD) $(top_builddir)/lib/libpatch.a $(LIB_CLOCK_GETTIME) \ +- $(LIB_XATTR) ++ $(LIB_XATTR) -lselinux + + if ENABLE_MERGE + patch_SOURCES += merge.c +diff -up patch-2.7/src/Makefile.in.selinux patch-2.7/src/Makefile.in +--- patch-2.7/src/Makefile.in.selinux 2012-09-12 02:40:57.000000000 +0100 ++++ patch-2.7/src/Makefile.in 2012-10-18 17:04:21.217420203 +0100 +@@ -989,7 +989,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) \ +- $(LIB_XATTR) ++ $(LIB_XATTR) -lselinux + + all: all-am + +diff -up patch-2.7/src/patch.c.selinux patch-2.7/src/patch.c +--- patch-2.7/src/patch.c.selinux 2012-08-08 12:24:46.000000000 +0100 ++++ patch-2.7/src/patch.c 2012-10-18 17:04:21.219420213 +0100 +@@ -552,7 +552,7 @@ main (int argc, char **argv) + mode, &new_time); + else + { +- attr |= FA_IDS | FA_MODE | FA_XATTRS; ++ attr |= FA_IDS | FA_MODE | FA_XATTRS | FA_SECCONTEXT; + set_file_attributes (TMPOUTNAME, attr, inname, &instat, + mode, &new_time); } - } -diff -up patch-2.6.1/src/pch.c.selinux patch-2.6.1/src/pch.c ---- patch-2.6.1/src/pch.c.selinux 2011-05-04 16:17:59.000000000 +0200 -+++ patch-2.6.1/src/pch.c 2011-05-04 16:49:45.000000000 +0200 -@@ -289,7 +289,12 @@ there_is_another_patch (bool need_header +diff -up patch-2.7/src/pch.c.selinux patch-2.7/src/pch.c +--- patch-2.7/src/pch.c.selinux 2012-08-11 09:19:49.000000000 +0100 ++++ patch-2.7/src/pch.c 2012-10-18 17:04:21.220420217 +0100 +@@ -295,7 +295,12 @@ there_is_another_patch (bool need_header inname[t - buf - 1] = 0; - if (stat (inname, &instat) == 0) + if (lstat (inname, &instat) == 0) { - inerrno = 0; + inerrno = getfilecon (inname, &incontext) == -1 ? errno : 0; -+ if (inerrno == ENODATA || inerrno == ENOTSUP) ++ if (errno == ENODATA || inerrno == ENOTSUP) + { + inerrno = 0; + incontext = NULL; @@ -113,7 +115,7 @@ diff -up patch-2.6.1/src/pch.c.selinux patch-2.6.1/src/pch.c invc = -1; } else -@@ -663,7 +668,7 @@ intuit_diff_type (bool need_header) +@@ -927,7 +932,7 @@ intuit_diff_type (bool need_header, mode if (cs) { if (version_get (p_name[i], cs, false, readonly, @@ -122,20 +124,40 @@ diff -up patch-2.6.1/src/pch.c.selinux patch-2.6.1/src/pch.c stat_errno[i] = 0; else version_controlled[i] = 0; -@@ -728,6 +733,9 @@ intuit_diff_type (bool need_header) +@@ -993,6 +998,9 @@ intuit_diff_type (bool need_header, mode + inerrno = stat_errno[i]; invc = version_controlled[i]; instat = st[i]; - validate_target_name (inname); + if (getfilecon (inname, &incontext) == -1) + if (errno == ENODATA || errno == ENOTSUP) + incontext = NULL; } return retval; -diff -up patch-2.6.1/src/util.c.selinux patch-2.6.1/src/util.c ---- patch-2.6.1/src/util.c.selinux 2009-11-02 19:09:57.000000000 +0000 -+++ patch-2.6.1/src/util.c 2011-02-08 11:29:34.613271715 +0000 -@@ -574,7 +574,8 @@ version_controller (char const *filename +diff -up patch-2.7/src/util.c.selinux patch-2.7/src/util.c +--- patch-2.7/src/util.c.selinux 2012-08-11 09:20:49.000000000 +0100 ++++ patch-2.7/src/util.c 2012-10-18 17:20:25.397226771 +0100 +@@ -291,6 +291,19 @@ set_file_attributes (char const *to, enu + S_ISLNK (mode) ? "symbolic link" : "file", + quotearg (to)); + } ++ if (attr & FA_SECCONTEXT) ++ { ++ security_context_t outcontext; ++ if (incontext && getfilecon (to, &outcontext) != -1 && ++ outcontext && ++ strcmp (outcontext, incontext) && ++ setfilecon (to, incontext) != 0) ++ { ++ if (errno != ENOTSUP && errno != EPERM) ++ pfatal ("Can't set security context on file %s", ++ quotearg (to)); ++ } ++ } + } + + static void +@@ -807,7 +820,8 @@ version_controller (char const *filename Return true if successful. */ bool version_get (char const *filename, char const *cs, bool exists, bool readonly, @@ -145,7 +167,7 @@ diff -up patch-2.6.1/src/util.c.selinux patch-2.6.1/src/util.c { if (patch_get < 0) { -@@ -599,6 +600,13 @@ version_get (char const *filename, char +@@ -832,6 +846,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)); @@ -159,10 +181,10 @@ diff -up patch-2.6.1/src/util.c.selinux patch-2.6.1/src/util.c } return 1; -diff -up patch-2.6.1/src/util.h.selinux patch-2.6.1/src/util.h ---- patch-2.6.1/src/util.h.selinux 2009-11-02 19:09:57.000000000 +0000 -+++ patch-2.6.1/src/util.h 2011-02-08 11:29:34.614271726 +0000 -@@ -51,7 +51,7 @@ char *fetchname (char *, int, char **, t +diff -up patch-2.7/src/util.h.selinux patch-2.7/src/util.h +--- patch-2.7/src/util.h.selinux 2012-08-11 09:20:01.000000000 +0100 ++++ patch-2.7/src/util.h 2012-10-18 17:04:21.220420217 +0100 +@@ -45,7 +45,7 @@ char *parse_name (char const *, int, cha char *savebuf (char const *, size_t); char *savestr (char const *); char const *version_controller (char const *, bool, struct stat const *, char **, char **); @@ -170,4 +192,14 @@ diff -up patch-2.6.1/src/util.h.selinux patch-2.6.1/src/util.h +bool version_get (char const *, char const *, bool, bool, char const *, struct stat *, security_context_t *); int create_file (char const *, int, mode_t, bool); int systemic (char const *); - char *format_linenum (char[LINENUM_LENGTH_BOUND + 1], LINENUM); + char *format_linenum (char[LINENUM_LENGTH_BOUND + 1], lin); +@@ -73,7 +73,8 @@ enum file_attributes { + FA_TIMES = 1, + FA_IDS = 2, + FA_MODE = 4, +- FA_XATTRS = 8 ++ FA_XATTRS = 8, ++ FA_SECCONTEXT = 16 + }; + + void set_file_attributes (char const *, enum file_attributes, char const *, diff --git a/patch.spec b/patch.spec index be16a6a..8712b25 100644 --- a/patch.spec +++ b/patch.spec @@ -1,16 +1,11 @@ Summary: Utility for modifying/upgrading files Name: patch -Version: 2.6.1 -Release: 13%{?dist} +Version: 2.7 +Release: 1%{?dist} License: GPLv2+ 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-2.5.4-sigsegv.patch -Patch2: patch-get-arg.patch -Patch3: patch-CVE-2010-4651.patch -Patch4: patch-backup-if-mismatch.patch -Patch5: patch-coverity-leak.patch Patch100: patch-selinux.patch Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) @@ -30,23 +25,6 @@ applications. %prep %setup -q -# Avoid segfault. -%patch1 -p1 -b .sigsegv - -# Fixed argument type for --get (bug #553624). -%patch2 -p1 -b .get-arg - -# Applied upstream patch to fix CVE-2010-4651 so that malicious -# patches cannot create files above the current directory -# (bug #667529). -%patch3 -p1 -b .CVE-2010-4651 - -# Let --posix cause --no-backup-if-mismatch (bug #678016). -%patch4 -p1 -b .backup-if-mismatch - -# Fix memory leak (bug #704554). -%patch5 -p1 -b .coverity-leak - # SELinux support. %patch100 -p1 -b .selinux @@ -75,6 +53,10 @@ rm -rf $RPM_BUILD_ROOT %{_mandir}/*/* %changelog +* Thu Oct 18 2012 Tim Waugh 2.7-1 +- 2.7. No longer need sigsegv, get-arg, CVE-2010-4651, + backup-if-mismatch or coverity-leak patches. + * Fri Jul 20 2012 Fedora Release Engineering - 2.6.1-13 - Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild diff --git a/sources b/sources index 1dd45ef..efb49a2 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -057d78436e858c3ed086a544f5e1fe7e patch-2.6.1.tar.xz +d443f9d9a7d1bf1715831883917699d9 patch-2.7.tar.xz