diff options
author | Richard Jones <rjones@trick.home.annexia.org> | 2009-07-27 22:27:45 +0100 |
---|---|---|
committer | Richard Jones <rjones@trick.home.annexia.org> | 2009-07-28 10:57:57 +0100 |
commit | 0f2e9c84e9ff1071260770930068642ecc8ac0d9 (patch) | |
tree | f4e466d6fb3710d589c21c8849c27f9f2f55ced2 /daemon/find.c | |
parent | bf920f57677c67f903cf8c4c985ce3d290b1dbde (diff) | |
download | libguestfs-0f2e9c84e9ff1071260770930068642ecc8ac0d9.tar.gz libguestfs-0f2e9c84e9ff1071260770930068642ecc8ac0d9.tar.xz libguestfs-0f2e9c84e9ff1071260770930068642ecc8ac0d9.zip |
Replace shell_quote function with %Q and %R printf specifiers.
%Q => simple shell quoted string
%R => path will be prefixed by /sysroot
eg. snprintf (cmd, sizeof cmd, "cat %R", path); system (cmd);
Diffstat (limited to 'daemon/find.c')
-rw-r--r-- | daemon/find.c | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/daemon/find.c b/daemon/find.c index d8829530..40f1b3bc 100644 --- a/daemon/find.c +++ b/daemon/find.c @@ -83,21 +83,14 @@ do_find (char *dir) sysrootdirlen = strlen (sysrootdir); /* Assemble the external find command. */ - len = 2 * sysrootdirlen + 32; - cmd = malloc (len); - if (!cmd) { + if (asprintf_nowarn (&cmd, "find %Q -print0", sysrootdir) == -1) { reply_with_perror ("malloc"); free (sysrootdir); return NULL; } - strcpy (cmd, "find "); - shell_quote (cmd+5, len-5, sysrootdir); - free (sysrootdir); - strcat (cmd, " -print0"); - if (verbose) - printf ("%s\n", cmd); + fprintf (stderr, "%s\n", cmd); fp = popen (cmd, "r"); if (fp == NULL) { |