aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2016-11-10 12:48:19 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2016-11-10 12:48:19 +0200
commit7d55037f89ab630125c37e6fc571cf36bb0a94c3 (patch)
treed1d4c1c4b5135c9b9b05f9a791403cd3f5eb8361
parent8fedf598c85f2fc5c68c96eebdc5753a89be7137 (diff)
downloadcpio-7d55037f89ab630125c37e6fc571cf36bb0a94c3.tar.gz
cpio-7d55037f89ab630125c37e6fc571cf36bb0a94c3.tar.bz2
Fix out-of-bounds read
* src/copyin.c (process_copy_in): Skip records with zero filename length.
-rw-r--r--src/copyin.c41
1 files changed, 23 insertions, 18 deletions
diff --git a/src/copyin.c b/src/copyin.c
index cde911e..05279d2 100644
--- a/src/copyin.c
+++ b/src/copyin.c
@@ -1378,30 +1378,35 @@ process_copy_in ()
}
#endif
- /* Is this the header for the TRAILER file? */
- if (strcmp (CPIO_TRAILER_NAME, file_hdr.c_name) == 0)
+ if (file_hdr.c_namesize == 0)
+ skip_file = true;
+ else
{
- done = true;
- break;
- }
+ /* Is this the header for the TRAILER file? */
+ if (strcmp (CPIO_TRAILER_NAME, file_hdr.c_name) == 0)
+ {
+ done = true;
+ break;
+ }
- cpio_safer_name_suffix (file_hdr.c_name, false, !no_abs_paths_flag,
- false);
+ cpio_safer_name_suffix (file_hdr.c_name, false, !no_abs_paths_flag,
+ false);
- /* Does the file name match one of the given patterns? */
- if (num_patterns <= 0)
- skip_file = false;
- else
- {
- skip_file = copy_matching_files;
- for (i = 0; i < num_patterns
- && skip_file == copy_matching_files; i++)
+ /* Does the file name match one of the given patterns? */
+ if (num_patterns <= 0)
+ skip_file = false;
+ else
{
- if (fnmatch (save_patterns[i], file_hdr.c_name, 0) == 0)
- skip_file = !copy_matching_files;
+ skip_file = copy_matching_files;
+ for (i = 0; i < num_patterns
+ && skip_file == copy_matching_files; i++)
+ {
+ if (fnmatch (save_patterns[i], file_hdr.c_name, 0) == 0)
+ skip_file = !copy_matching_files;
+ }
}
}
-
+
if (skip_file)
{
/* If we're skipping a file with links, there might be other

Return to:

Send suggestions and report system problems to the System administrator.