aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry V. Levin <ldv@altlinux.org>2010-03-01 03:49:53 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2010-07-22 12:54:07 +0300
commitf40dd3ef902337afd9c5ccc6d69538e155ea26e7 (patch)
tree3b763a670b154aebc528d043a3996128a55af221
parent211c804e8adbe223a96c3e8fb569ec6874cce838 (diff)
downloadcpio-f40dd3ef902337afd9c5ccc6d69538e155ea26e7.tar.gz
cpio-f40dd3ef902337afd9c5ccc6d69538e155ea26e7.tar.bz2
Fix --to-stdout option support
* src/copyin.c (copyin_link): Skip an appropriate number of bytes when to_stdout_option flag is set. * tests/symlink-to-stdout.at: New test case. * tests/Makefile.am (TESTSUITE_AT): Add symlink-to-stdout.at. * tests/testsuite.at: Include symlink-to-stdout.at.
-rw-r--r--src/copyin.c11
-rw-r--r--tests/Makefile.am1
-rw-r--r--tests/symlink-to-stdout.at37
-rw-r--r--tests/testsuite.at1
4 files changed, 47 insertions, 3 deletions
diff --git a/src/copyin.c b/src/copyin.c
index ac921e1..44b694d 100644
--- a/src/copyin.c
+++ b/src/copyin.c
@@ -645,11 +645,14 @@ 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. */
- if (to_stdout_option)
- return;
-
if (archive_format != arf_tar && archive_format != arf_ustar)
{
+ if (to_stdout_option)
+ {
+ tape_toss_input (in_file_des, file_hdr->c_filesize);
+ tape_skip_padding (in_file_des, file_hdr->c_filesize);
+ return;
+ }
link_name = (char *) xmalloc ((unsigned int) file_hdr->c_filesize + 1);
link_name[file_hdr->c_filesize] = '\0';
tape_buffered_read (link_name, in_file_des, file_hdr->c_filesize);
@@ -657,6 +660,8 @@ copyin_link(struct cpio_file_stat *file_hdr, int in_file_des)
}
else
{
+ if (to_stdout_option)
+ return;
link_name = xstrdup (file_hdr->c_tar_linkname);
}
diff --git a/tests/Makefile.am b/tests/Makefile.am
index b3e8e60..b63b545 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -52,6 +52,7 @@ TESTSUITE_AT = \
setstat04.at\
setstat05.at\
symlink.at\
+ symlink-to-stdout.at\
version.at
TESTSUITE = $(srcdir)/testsuite
diff --git a/tests/symlink-to-stdout.at b/tests/symlink-to-stdout.at
new file mode 100644
index 0000000..de2e0a2
--- /dev/null
+++ b/tests/symlink-to-stdout.at
@@ -0,0 +1,37 @@
+# Process this file with autom4te to create testsuite. -*- Autotest -*-
+# Copyright (C) 2006, 2007, 2010 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
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 USA.
+
+# Description: Cpio versions up to 2.10.91 failed to copy files out
+# of an archive to standard output (with --to-stdout option),
+# if the archive contained a symlink.
+
+AT_SETUP([symlink --to-stdout])
+AT_KEYWORDS([symlink --to-stdout])
+
+AT_DATA([filelist],[file
+symlink
+])
+
+AT_CHECK([
+genfile --file file
+ln -s file symlink || AT_SKIP_TEST
+cpio --quiet -o < filelist > archive || exit
+cpio --quiet --to-stdout -i < archive > output || exit
+cmp file output])
+
+AT_CLEANUP
diff --git a/tests/testsuite.at b/tests/testsuite.at
index 8f3330b..9731321 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -31,6 +31,7 @@ m4_include([version.at])
m4_include([inout.at])
m4_include([symlink.at])
+m4_include([symlink-to-stdout.at])
m4_include([interdir.at])
m4_include([setstat01.at])

Return to:

Send suggestions and report system problems to the System administrator.