aboutsummaryrefslogtreecommitdiff
path: root/src/copyin.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2014-12-11 12:51:21 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2014-12-11 12:55:24 +0200
commitfd262d116c4564c1796be9be2799619cf7785d07 (patch)
tree36bd2a892e73284250227d45bb5b28e1918c77f0 /src/copyin.c
parent58df4f1b44a1142bba500f980fd26806413b1728 (diff)
downloadcpio-fd262d116c4564c1796be9be2799619cf7785d07.tar.gz
cpio-fd262d116c4564c1796be9be2799619cf7785d07.tar.bz2
Fix error recovery in copy-in mode
* src/copyin.c (copyin_link): Fix null dereference. (read_in_header): Fix error recovery (bug introduced by 27e0ae55). * tests/symlink-bad-length.at: Test error recovery. Catch various architecture-dependent error messages (suggested by Pavel Raiskup).
Diffstat (limited to 'src/copyin.c')
-rw-r--r--src/copyin.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/copyin.c b/src/copyin.c
index 264bfcb..ca12356 100644
--- a/src/copyin.c
+++ b/src/copyin.c
@@ -645,7 +645,7 @@ copyin_device (struct cpio_file_stat* file_hdr)
}
static void
-copyin_link(struct cpio_file_stat *file_hdr, int in_file_des)
+copyin_link (struct cpio_file_stat *file_hdr, int in_file_des)
{
char *link_name = NULL; /* Name of hard and symbolic links. */
int res; /* Result of various function calls. */
@@ -659,6 +659,8 @@ copyin_link(struct cpio_file_stat *file_hdr, int in_file_des)
return;
}
link_name = get_link_name (file_hdr, in_file_des);
+ if (!link_name)
+ return;
}
else
{
@@ -1012,7 +1014,7 @@ read_in_header (struct cpio_file_stat *file_hdr, int in_des)
file_hdr->c_tar_linkname = NULL;
- tape_buffered_read (magic.str, in_des, 6L);
+ tape_buffered_read (magic.str, in_des, sizeof (magic.str));
while (1)
{
if (append_flag)
@@ -1057,8 +1059,8 @@ read_in_header (struct cpio_file_stat *file_hdr, int in_des)
break;
}
bytes_skipped++;
- memmove (magic.str, magic.str + 1, 5);
- tape_buffered_read (magic.str, in_des, 1L);
+ memmove (magic.str, magic.str + 1, sizeof (magic.str) - 1);
+ tape_buffered_read (magic.str + sizeof (magic.str) - 1, in_des, 1L);
}
}

Return to:

Send suggestions and report system problems to the System administrator.