#endif
archive_handle = init_handle();
- archive_handle->src_fd = STDIN_FILENO;
+ /* archive_handle->src_fd = STDIN_FILENO; - done by init_handle */
archive_handle->seek = seek_by_read;
archive_handle->ah_flags = ARCHIVE_EXTRACT_NEWER;
file_header->name = xzalloc(namesize + 1);
/* Read in filename */
xread(archive_handle->src_fd, file_header->name, namesize);
+ if (file_header->name[0] == '/') {
+ /* Testcase: echo /etc/hosts | cpio -pvd /tmp
+ * Without this code, it tries to unpack /etc/hosts
+ * into "/etc/hosts", not "etc/hosts".
+ */
+ char *p = file_header->name;
+ do p++; while (*p == '/');
+ overlapping_strcpy(file_header->name, p);
+ }
archive_handle->offset += namesize;
/* Update offset amount and skip padding before file contents */
"\
1 blocks
0
+total 0
-rw-r--r-- 2 $user $group 0 x
-rw-r--r-- 2 $user $group 0 y
" \
testing "cpio lists hardlinks" \
"$ECHO -ne '$hexdump' | bzcat | cpio -t 2>&1; echo \$?" \
"\
-1 block
cpio.testdir
cpio.testdir/x
cpio.testdir/y
+1 blocks
0
" \
"" ""
"\
2 blocks
0
+total 8
-rw-r--r-- 2 $user $group 0 empty
-rw-r--r-- 2 $user $group 0 empty1
-rw-r--r-- 2 $user $group 2 nonempty