X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=daemon%2Fgrub.c;h=86e812e9a49c725936f8e6853c0b88d3b61ae90e;hp=29fe294b98146a0936a7ba8f006c2af6fb15516c;hb=13a499406fe43ab3a6d4d13c660f6a8b368e638f;hpb=a7b73d4a1e09f12b2002083618056f0c823c1dcf diff --git a/daemon/grub.c b/daemon/grub.c index 29fe294..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) + 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=/sysroot%s", root); r = command (NULL, &err, "/sbin/grub-install", buf, device, NULL); free (buf);