X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=daemon%2Fgrub.c;h=86e812e9a49c725936f8e6853c0b88d3b61ae90e;hp=3b1768f23a9b2947f3638b8d7ab8921240fe6a3b;hb=0f2e9c84e9ff1071260770930068642ecc8ac0d9;hpb=bf920f57677c67f903cf8c4c985ce3d290b1dbde diff --git a/daemon/grub.c b/daemon/grub.c index 3b1768f..86e812e 100644 --- a/daemon/grub.c +++ b/daemon/grub.c @@ -28,7 +28,7 @@ int do_grub_install (char *root, char *device) { - int r, len; + int r; char *err; char *buf; @@ -36,13 +36,10 @@ do_grub_install (char *root, char *device) ABS_PATH (root, -1); IS_DEVICE (device, -1); - len = strlen (root) + sysroot_len + 64; - buf = malloc (len); - if (!buf) { - reply_with_perror ("malloc"); + if (asprintf_nowarn (&buf, "--root-directory=%R", root) == -1) { + reply_with_perror ("asprintf"); return -1; } - snprintf (buf, len, "--root-directory=%s%s", sysroot, root); r = command (NULL, &err, "/sbin/grub-install", buf, device, NULL); free (buf);