aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2019-11-08 09:09:36 +0200
committerSergey Poznyakoff <gray@gnu.org>2019-11-08 09:09:36 +0200
commit684b7ac5767e676cda78c161aeb7fe7b45a07529 (patch)
tree410866246e3dd8ca3ef82592735d630687da6049
parentcd892d109a583e3a29e1da66b8374c29605bfdc8 (diff)
downloadcpio-684b7ac5767e676cda78c161aeb7fe7b45a07529.tar.gz
cpio-684b7ac5767e676cda78c161aeb7fe7b45a07529.tar.bz2
Fix cpio header verification.
* src/copyin.c (read_name_from_file): Print error message and skip file if its name is not nul-terminated.
-rw-r--r--src/copyin.c9
-rw-r--r--tests/testsuite.at3
2 files changed, 9 insertions, 3 deletions
diff --git a/src/copyin.c b/src/copyin.c
index b29f348..9348923 100644
--- a/src/copyin.c
+++ b/src/copyin.c
@@ -1002,3 +1002,10 @@ read_name_from_file (struct cpio_file_stat *file_hdr, int fd, uintmax_t len)
tape_buffered_read (file_hdr->c_name, fd, len);
- file_hdr->c_namesize = len;
+ if (file_hdr->c_name[len-1] == 0)
+ file_hdr->c_namesize = len;
+ else
+ {
+ error (0, 0, _("malformed header: file name is not nul-terminated"));
+ /* Skip this file */
+ file_hdr->c_namesize = 0;
+ }
}
diff --git a/tests/testsuite.at b/tests/testsuite.at
index aa56bb9..f901b1a 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -3,4 +3,3 @@
# Test suite for GNU cpio
-# Copyright (C) 2004, 2006-2007, 2010, 2014-2015, 2017 Free Software
-# Foundation, Inc.
+# Copyright (C) 2004-2019 Free Software Foundation, Inc.

Return to:

Send suggestions and report system problems to the System administrator.