cpio/cpio-2.14-patternnamesigsegv.patch
Lukas Javorsky 955b315761 Rebase to version 2.14
Patches applied: cpio-2.13-mutiple-definition.patch cpio-2.13-reset-gid-uid.patch
Other patches partly applied or not at all
New patch applied from http://git.savannah.gnu.org/cgit/cpio.git/commit/?id=a3eb338a40750ecfd73de7054d44e69008866621

Resolves: CVE-2015-1197
2023-05-25 13:36:39 +00:00

41 lines
1.3 KiB
Diff

From: =?UTF-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= <ovasik@redhat.com>
Date: Mon, 14 Sep 2015 09:47:05 +0200
Subject: [PATCH 5/7] fix segfault with nonexisting file with patternnames
(#567022)
diff --git a/src/copyin.c b/src/copyin.c
index 5d88a23..f2babb7 100644
--- a/src/copyin.c
+++ b/src/copyin.c
@@ -948,21 +948,24 @@ read_pattern_file (void)
pattern_fp = fopen (pattern_file_name, "r");
if (pattern_fp == NULL)
- open_fatal (pattern_file_name);
- while (ds_fgetstr (pattern_fp, &pattern_name, '\n') != NULL)
+ open_error (pattern_file_name);
+ else
+ {
+ while (ds_fgetstr (pattern_fp, &pattern_name, '\n') != NULL)
{
if (new_num_patterns == max_new_patterns)
- new_save_patterns = x2nrealloc (new_save_patterns,
+ new_save_patterns = x2nrealloc (new_save_patterns,
&max_new_patterns,
sizeof (new_save_patterns[0]));
new_save_patterns[new_num_patterns] = xstrdup (pattern_name.ds_string);
++new_num_patterns;
}
- ds_free (&pattern_name);
+ ds_free (&pattern_name);
- if (ferror (pattern_fp) || fclose (pattern_fp) == EOF)
- close_error (pattern_file_name);
+ 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];