diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2012-08-03 12:54:18 +0100 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2012-08-03 12:54:18 +0100 |
commit | 2a87261dfc830cd6bcb44aa1628d955cb6423bd7 (patch) | |
tree | 5fb3fe32ab08bd78058cec24f26904c75a7d1611 | |
parent | 7fa67427c6b2725bdcce52c08511f8813b7bd42e (diff) | |
download | libguestfs-2a87261dfc830cd6bcb44aa1628d955cb6423bd7.tar.gz libguestfs-2a87261dfc830cd6bcb44aa1628d955cb6423bd7.tar.xz libguestfs-2a87261dfc830cd6bcb44aa1628d955cb6423bd7.zip |
fish: Fix 'copy-out /' (RHBZ#845522).
-rw-r--r-- | fish/copy.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/fish/copy.c b/fish/copy.c index 0ea605f9..f29d6ef2 100644 --- a/fish/copy.c +++ b/fish/copy.c @@ -27,6 +27,7 @@ #include <sys/types.h> #include <sys/stat.h> #include <sys/wait.h> +#include <assert.h> #include "fish.h" @@ -276,6 +277,13 @@ run_copy_out (const char *cmd, size_t argc, char *argv[]) return -1; } + /* RHBZ#845522: If remote == "/" then basename would be an empty + * string. Replace it with "." so that make_tar_output writes + * to "local/." + */ + if (STREQ (basename, "")) + basename = "."; + struct fd_pid fdpid = make_tar_output (local, basename); if (fdpid.fd == -1) { free (remote); @@ -326,6 +334,14 @@ make_tar_output (const char *local, const char *basename) int fd[2]; struct fd_pid r = { .fd = -1 }; + /* local can't be an empty string because the caller stats it and + * checks it is a directory. + */ + assert (STRNEQ (local, "")); + + /* basename must not be an empty string (see RHBZ#845522). */ + assert (STRNEQ (basename, "")); + if (pipe (fd) == -1) { perror ("pipe"); return r; |