X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=daemon%2Fgrub.c;h=86e812e9a49c725936f8e6853c0b88d3b61ae90e;hb=4610db9f1b77f8c263b348fda1974be165a7f841;hp=3b1768f23a9b2947f3638b8d7ab8921240fe6a3b;hpb=78029b529ad98769685d607230b70f71832d5906;p=libguestfs.git 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);