aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/copyin.c20
1 files 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

Return to:

Send suggestions and report system problems to the System administrator.