Don't remove initrd= parameter.

Based on simplified patch by Lunar.

Reported by: Lunar
This commit is contained in:
Vladimir Serbinenko 2015-02-16 15:56:26 +01:00
parent b23635fcff
commit e29af836d0

View file

@ -869,7 +869,6 @@ write_entry (struct output_buffer *outbuf,
case KERNEL_LINUX: case KERNEL_LINUX:
{ {
char *ptr; char *ptr;
char *cmdline;
char *initrd = NULL; char *initrd = NULL;
for (ptr = curentry->append; ptr && *ptr; ptr++) for (ptr = curentry->append; ptr && *ptr; ptr++)
if ((ptr == curentry->append || grub_isspace (ptr[-1])) if ((ptr == curentry->append || grub_isspace (ptr[-1]))
@ -879,31 +878,19 @@ write_entry (struct output_buffer *outbuf,
if (ptr && *ptr) if (ptr && *ptr)
{ {
char *ptr2; char *ptr2;
grub_size_t totlen = grub_strlen (curentry->append); initrd = grub_strdup(ptr + sizeof ("initrd=") - 1);
initrd = ptr + sizeof ("initrd=") - 1; if (!initrd)
for (ptr2 = ptr; *ptr2 && !grub_isspace (*ptr2); ptr2++);
if (*ptr2)
{
*ptr2 = 0;
ptr2++;
}
cmdline = grub_malloc (totlen + 1 - (ptr2 - ptr));
if (!cmdline)
return grub_errno; return grub_errno;
grub_memcpy (cmdline, curentry->append, ptr - curentry->append); for (ptr2 = initrd; *ptr2 && !grub_isspace (*ptr2); ptr2++);
grub_memcpy (cmdline + (ptr - curentry->append), *ptr2 = 0;
ptr2, totlen - (ptr2 - curentry->append));
*(cmdline + totlen - (ptr2 - ptr)) = 0;
} }
else
cmdline = curentry->append;
print_string (" if test x$grub_platform = xpc; then " print_string (" if test x$grub_platform = xpc; then "
"linux_suffix=16; else linux_suffix= ; fi\n"); "linux_suffix=16; else linux_suffix= ; fi\n");
print_string (" linux$linux_suffix "); print_string (" linux$linux_suffix ");
print_file (outbuf, menu, curentry->kernel_file, NULL); print_file (outbuf, menu, curentry->kernel_file, NULL);
print_string (" "); print_string (" ");
if (cmdline) if (curentry->append)
print (outbuf, cmdline, grub_strlen (cmdline)); print (outbuf, curentry->append, grub_strlen (curentry->append));
print_string ("\n"); print_string ("\n");
if (initrd || curentry->initrds) if (initrd || curentry->initrds)
{ {
@ -922,8 +909,7 @@ write_entry (struct output_buffer *outbuf,
print_string ("\n"); print_string ("\n");
} }
if (ptr && *ptr) grub_free (initrd);
grub_free (cmdline);
} }
break; break;
case KERNEL_CHAINLOADER: case KERNEL_CHAINLOADER: