X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=daemon%2Ffind.c;h=c514177ac19a95f6ef5eb20da43cf44daa815ef2;hb=0dd6c8c8442d4ff588f6dac2efab24d3409b0dec;hp=d8829530827d2d05846cc983a1db72233cc12111;hpb=78029b529ad98769685d607230b70f71832d5906;p=libguestfs.git diff --git a/daemon/find.c b/daemon/find.c index d882953..c514177 100644 --- a/daemon/find.c +++ b/daemon/find.c @@ -60,7 +60,7 @@ do_find (char *dir) char str[PATH_MAX]; NEED_ROOT (NULL); - ABS_PATH (dir, NULL); + ABS_PATH (dir, return NULL); sysrootdir = sysroot_path (dir); if (!sysrootdir) { @@ -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) {