aboutsummaryrefslogtreecommitdiff
path: root/archival/libunarchive
diff options
context:
space:
mode:
Diffstat (limited to 'archival/libunarchive')
-rw-r--r--archival/libunarchive/get_header_cpio.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/archival/libunarchive/get_header_cpio.c b/archival/libunarchive/get_header_cpio.c
index 302f12233..52854dff9 100644
--- a/archival/libunarchive/get_header_cpio.c
+++ b/archival/libunarchive/get_header_cpio.c
@@ -70,6 +70,15 @@ char FAST_FUNC get_header_cpio(archive_handle_t *archive_handle)
70 file_header->name = xzalloc(namesize + 1); 70 file_header->name = xzalloc(namesize + 1);
71 /* Read in filename */ 71 /* Read in filename */
72 xread(archive_handle->src_fd, file_header->name, namesize); 72 xread(archive_handle->src_fd, file_header->name, namesize);
73 if (file_header->name[0] == '/') {
74 /* Testcase: echo /etc/hosts | cpio -pvd /tmp
75 * Without this code, it tries to unpack /etc/hosts
76 * into "/etc/hosts", not "etc/hosts".
77 */
78 char *p = file_header->name;
79 do p++; while (*p == '/');
80 overlapping_strcpy(file_header->name, p);
81 }
73 archive_handle->offset += namesize; 82 archive_handle->offset += namesize;
74 83
75 /* Update offset amount and skip padding before file contents */ 84 /* Update offset amount and skip padding before file contents */