summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org>2019-11-08 07:09:36 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2019-11-08 07:09:36 (GMT)
commit684b7ac5767e676cda78c161aeb7fe7b45a07529 (patch) (side-by-side diff)
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.
Diffstat (more/less context) (ignore whitespace changes)
-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
@@ -1000,7 +1000,14 @@ 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);
- 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;
+ }
}
/* Fill in FILE_HDR by reading an old-format ASCII format cpio header from
diff --git a/tests/testsuite.at b/tests/testsuite.at
index aa56bb9..f901b1a 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -1,8 +1,7 @@
# Process this file with autom4te to create testsuite. -*- Autotest -*-
# 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.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

Return to:

Send suggestions and report system problems to the System administrator.