Blame SOURCES/cpio-2.10-patternnamesigsegv.patch

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