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-05 22:48:54 +0100 |
commit | 7ab3b7ad079675142ba3d46e1f80f156916139ba (patch) | |
tree | 1aa1500005e56d87501a0c7b81c646f562c455f9 /fish/copy.c | |
parent | 369565a3ac6492586b27c70a651b2af8e28e220a (diff) | |
download | libguestfs-7ab3b7ad079675142ba3d46e1f80f156916139ba.tar.gz libguestfs-7ab3b7ad079675142ba3d46e1f80f156916139ba.tar.xz libguestfs-7ab3b7ad079675142ba3d46e1f80f156916139ba.zip |
fish: Fix 'copy-out /' (RHBZ#845522).
(cherry picked from commit 2a87261dfc830cd6bcb44aa1628d955cb6423bd7)
Diffstat (limited to 'fish/copy.c')
-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 4ff1693f..3486bf86 100644 --- a/fish/copy.c +++ b/fish/copy.c @@ -26,6 +26,7 @@ #include <sys/types.h> #include <sys/stat.h> #include <sys/wait.h> +#include <assert.h> #include "fish.h" @@ -275,6 +276,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); @@ -325,6 +333,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; |