X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=daemon%2Ffind.c;h=40f1b3bce59d990e135f46b88ff83f99b77e4d17;hp=d8829530827d2d05846cc983a1db72233cc12111;hb=0f2e9c84e9ff1071260770930068642ecc8ac0d9;hpb=bf920f57677c67f903cf8c4c985ce3d290b1dbde;ds=sidebyside diff --git a/daemon/find.c b/daemon/find.c index d882953..40f1b3b 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) {