Sophie

Sophie

distrib > Mageia > 7 > i586 > by-pkgid > 26d15f24ee2c547d4637f284799f455c > files > 2

cpio-2.13-1.1.mga7.src.rpm

From b1c85839bf1381f749dd45bf6a5a38924e3315a0 Mon Sep 17 00:00:00 2001
From: Sergey Poznyakoff <gray@gnu.org>
Date: Fri, 8 Nov 2019 11:20:32 +0200
Subject: [PATCH 2/2] Improve 684b7ac5

* src/copyin.c (read_name_from_file): Handle len == 0.
---
 src/copyin.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/src/copyin.c b/src/copyin.c
index 9348923..2e7feb1 100644
--- a/src/copyin.c
+++ b/src/copyin.c
@@ -998,16 +998,22 @@ read_in_header (struct cpio_file_stat *file_hdr, int in_des)
 static void
 read_name_from_file (struct cpio_file_stat *file_hdr, int fd, uintmax_t len)
 {
-  cpio_realloc_c_name (file_hdr, len);
-  tape_buffered_read (file_hdr->c_name, fd, len);
-  if (file_hdr->c_name[len-1] == 0)
-    file_hdr->c_namesize = len;
+  if (len == 0)
+    {
+      error (0, 0, _("malformed header: file name of zero length"));
+    }
   else
     {
-      error (0, 0, _("malformed header: file name is not nul-terminated"));
-      /* Skip this file */
-      file_hdr->c_namesize = 0;
+      cpio_realloc_c_name (file_hdr, len);
+      tape_buffered_read (file_hdr->c_name, fd, len);
+      if (file_hdr->c_name[len-1] != 0)
+	{
+	  error (0, 0, _("malformed header: file name is not nul-terminated"));
+	  /* Skip this file */
+	  len = 0;
+	}
     }
+  file_hdr->c_namesize = len;
 }
 
 /* Fill in FILE_HDR by reading an old-format ASCII format cpio header from
-- 
2.23.0