Blame SOURCES/cpio-2.10-patternnamesigsegv.patch

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