fix segfault with nonexisting file with patternnames (#567022)

This commit is contained in:
Ondrej Vasik 2010-02-22 12:19:44 +00:00
parent 880ab2fd12
commit 8f8ac398f5
2 changed files with 48 additions and 1 deletions

View File

@ -0,0 +1,41 @@
diff -urNp cpio-2.10-orig/src/copyin.c cpio-2.10/src/copyin.c
--- cpio-2.10-orig/src/copyin.c 2010-02-22 12:57:59.000000000 +0100
+++ cpio-2.10/src/copyin.c 2010-02-22 12:55:26.000000000 +0100
@@ -944,20 +944,23 @@ read_pattern_file ()
pattern_fp = fopen (pattern_file_name, "r");
if (pattern_fp == NULL)
open_error (pattern_file_name);
- while (ds_fgetstr (pattern_fp, &pattern_name, '\n') != NULL)
- {
- if (new_num_patterns >= max_new_patterns)
- {
- max_new_patterns += 1;
- new_save_patterns = (char **)
- xrealloc ((char *) new_save_patterns,
- max_new_patterns * sizeof (char *));
- }
- new_save_patterns[new_num_patterns] = xstrdup (pattern_name.ds_string);
- ++new_num_patterns;
- }
- if (ferror (pattern_fp) || fclose (pattern_fp) == EOF)
- close_error (pattern_file_name);
+ else
+ {
+ while (ds_fgetstr (pattern_fp, &pattern_name, '\n') != NULL)
+ {
+ if (new_num_patterns >= max_new_patterns)
+ {
+ max_new_patterns += 1;
+ new_save_patterns = (char **)
+ xrealloc ((char *) new_save_patterns,
+ max_new_patterns * sizeof (char *));
+ }
+ new_save_patterns[new_num_patterns] = xstrdup (pattern_name.ds_string);
+ ++new_num_patterns;
+ }
+ if (ferror (pattern_fp) || fclose (pattern_fp) == EOF)
+ close_error (pattern_file_name);
+ }
for (i = 0; i < num_patterns; ++i)
new_save_patterns[i] = save_patterns[i];

View File

@ -3,7 +3,7 @@
Summary: A GNU archiving program
Name: cpio
Version: 2.10
Release: 4%{?dist}
Release: 5%{?dist}
License: GPLv3+
Group: Applications/Archiving
URL: http://www.gnu.org/software/cpio/
@ -18,6 +18,7 @@ Patch6: cpio-2.9-dev_number.patch
Patch7: cpio-2.9-sys_umask.patch
Patch8: cpio-2.9.90-defaultremoteshell.patch
Patch9: cpio-2.10-utimens.patch
Patch10: cpio-2.10-patternnamesigsegv.patch
Requires(post): /sbin/install-info
Requires(preun): /sbin/install-info
BuildRequires: texinfo, autoconf, gettext, rmt
@ -48,6 +49,7 @@ Install cpio if you need a program to manage file archives.
%patch7 -p1 -b .sys_umask
%patch8 -p1 -b .defaultremote
%patch9 -p1 -b .utimens
%patch10 -p1 -b .patternsegv
autoheader
@ -92,6 +94,10 @@ fi
%{_infodir}/*.info*
%changelog
* Mon Feb 22 2010 Ondrej Vasik <ovasik@redhat.com> 2.10-5
- fix segfault with nonexisting file with patternnames
(#567022)
* Wed Jan 06 2010 Ondrej Vasik <ovasik@redhat.com> 2.10-4
- do not fail with new POSIX 2008 utimens() glibc call
(#552320)