* grub-core/loader/i386/multiboot_mbi.c: Handle space in command line.
* grub-core/loader/multiboot_mbi2.c: Likewise.
This commit is contained in:
parent
2df1255117
commit
1a46a3a4b3
4 changed files with 28 additions and 76 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2013-11-09 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* grub-core/loader/i386/multiboot_mbi.c: Handle space in command line.
|
||||||
|
* grub-core/loader/multiboot_mbi2.c: Likewise.
|
||||||
|
|
||||||
2013-11-09 Vladimir Serbinenko <phcoder@gmail.com>
|
2013-11-09 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
* grub-core/lib/cmdline.c (grub_loader_cmdline_size): Fix empty cmdline
|
* grub-core/lib/cmdline.c (grub_loader_cmdline_size): Fix empty cmdline
|
||||||
|
|
|
@ -1576,6 +1576,7 @@ module = {
|
||||||
cppflags = "-DGRUB_USE_MULTIBOOT2";
|
cppflags = "-DGRUB_USE_MULTIBOOT2";
|
||||||
|
|
||||||
common = loader/multiboot.c;
|
common = loader/multiboot.c;
|
||||||
|
common = lib/cmdline.c;
|
||||||
common = loader/multiboot_mbi2.c;
|
common = loader/multiboot_mbi2.c;
|
||||||
enable = x86;
|
enable = x86;
|
||||||
enable = mips;
|
enable = mips;
|
||||||
|
@ -1584,6 +1585,7 @@ module = {
|
||||||
module = {
|
module = {
|
||||||
name = multiboot;
|
name = multiboot;
|
||||||
common = loader/multiboot.c;
|
common = loader/multiboot.c;
|
||||||
|
common = lib/cmdline.c;
|
||||||
x86 = loader/i386/multiboot_mbi.c;
|
x86 = loader/i386/multiboot_mbi.c;
|
||||||
extra_dist = loader/multiboot_elfxx.c;
|
extra_dist = loader/multiboot_elfxx.c;
|
||||||
enable = x86;
|
enable = x86;
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include <grub/file.h>
|
#include <grub/file.h>
|
||||||
#include <grub/net.h>
|
#include <grub/net.h>
|
||||||
#include <grub/i18n.h>
|
#include <grub/i18n.h>
|
||||||
|
#include <grub/lib/cmdline.h>
|
||||||
|
|
||||||
#ifdef GRUB_MACHINE_EFI
|
#ifdef GRUB_MACHINE_EFI
|
||||||
#include <grub/efi/efi.h>
|
#include <grub/efi/efi.h>
|
||||||
|
@ -641,31 +642,18 @@ grub_err_t
|
||||||
grub_multiboot_init_mbi (int argc, char *argv[])
|
grub_multiboot_init_mbi (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
grub_ssize_t len = 0;
|
grub_ssize_t len = 0;
|
||||||
char *p;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
grub_multiboot_free_mbi ();
|
grub_multiboot_free_mbi ();
|
||||||
|
|
||||||
for (i = 0; i < argc; i++)
|
len = grub_loader_cmdline_size (argc, argv);
|
||||||
len += grub_strlen (argv[i]) + 1;
|
|
||||||
if (len == 0)
|
|
||||||
len = 1;
|
|
||||||
|
|
||||||
cmdline = p = grub_malloc (len);
|
cmdline = grub_malloc (len);
|
||||||
if (! cmdline)
|
if (! cmdline)
|
||||||
return grub_errno;
|
return grub_errno;
|
||||||
cmdline_size = len;
|
cmdline_size = len;
|
||||||
|
|
||||||
for (i = 0; i < argc; i++)
|
grub_create_loader_cmdline (argc, argv, cmdline,
|
||||||
{
|
cmdline_size);
|
||||||
p = grub_stpcpy (p, argv[i]);
|
|
||||||
*(p++) = ' ';
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Remove the space after the last word. */
|
|
||||||
if (p != cmdline)
|
|
||||||
p--;
|
|
||||||
*p = '\0';
|
|
||||||
|
|
||||||
return GRUB_ERR_NONE;
|
return GRUB_ERR_NONE;
|
||||||
}
|
}
|
||||||
|
@ -675,9 +663,7 @@ grub_multiboot_add_module (grub_addr_t start, grub_size_t size,
|
||||||
int argc, char *argv[])
|
int argc, char *argv[])
|
||||||
{
|
{
|
||||||
struct module *newmod;
|
struct module *newmod;
|
||||||
char *p;
|
grub_size_t len = 0;
|
||||||
grub_ssize_t len = 0;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
newmod = grub_malloc (sizeof (*newmod));
|
newmod = grub_malloc (sizeof (*newmod));
|
||||||
if (!newmod)
|
if (!newmod)
|
||||||
|
@ -686,13 +672,9 @@ grub_multiboot_add_module (grub_addr_t start, grub_size_t size,
|
||||||
newmod->size = size;
|
newmod->size = size;
|
||||||
newmod->next = 0;
|
newmod->next = 0;
|
||||||
|
|
||||||
for (i = 0; i < argc; i++)
|
len = grub_loader_cmdline_size (argc, argv);
|
||||||
len += grub_strlen (argv[i]) + 1;
|
|
||||||
|
|
||||||
if (len == 0)
|
newmod->cmdline = grub_malloc (len);
|
||||||
len = 1;
|
|
||||||
|
|
||||||
newmod->cmdline = p = grub_malloc (len);
|
|
||||||
if (! newmod->cmdline)
|
if (! newmod->cmdline)
|
||||||
{
|
{
|
||||||
grub_free (newmod);
|
grub_free (newmod);
|
||||||
|
@ -701,24 +683,13 @@ grub_multiboot_add_module (grub_addr_t start, grub_size_t size,
|
||||||
newmod->cmdline_size = len;
|
newmod->cmdline_size = len;
|
||||||
total_modcmd += ALIGN_UP (len, 4);
|
total_modcmd += ALIGN_UP (len, 4);
|
||||||
|
|
||||||
for (i = 0; i < argc; i++)
|
grub_create_loader_cmdline (argc, argv, newmod->cmdline,
|
||||||
{
|
newmod->cmdline_size);
|
||||||
p = grub_stpcpy (p, argv[i]);
|
|
||||||
*(p++) = ' ';
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Remove the space after the last word. */
|
|
||||||
if (p != newmod->cmdline)
|
|
||||||
p--;
|
|
||||||
*p = '\0';
|
|
||||||
|
|
||||||
if (modules_last)
|
if (modules_last)
|
||||||
modules_last->next = newmod;
|
modules_last->next = newmod;
|
||||||
else
|
else
|
||||||
{
|
modules = newmod;
|
||||||
modules = newmod;
|
|
||||||
modules_last->next = NULL;
|
|
||||||
}
|
|
||||||
modules_last = newmod;
|
modules_last = newmod;
|
||||||
|
|
||||||
modcnt++;
|
modcnt++;
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include <grub/acpi.h>
|
#include <grub/acpi.h>
|
||||||
#include <grub/i18n.h>
|
#include <grub/i18n.h>
|
||||||
#include <grub/net.h>
|
#include <grub/net.h>
|
||||||
|
#include <grub/lib/cmdline.h>
|
||||||
|
|
||||||
#if defined (GRUB_MACHINE_EFI)
|
#if defined (GRUB_MACHINE_EFI)
|
||||||
#include <grub/efi/efi.h>
|
#include <grub/efi/efi.h>
|
||||||
|
@ -905,31 +906,18 @@ grub_err_t
|
||||||
grub_multiboot_init_mbi (int argc, char *argv[])
|
grub_multiboot_init_mbi (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
grub_ssize_t len = 0;
|
grub_ssize_t len = 0;
|
||||||
char *p;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
grub_multiboot_free_mbi ();
|
grub_multiboot_free_mbi ();
|
||||||
|
|
||||||
for (i = 0; i < argc; i++)
|
len = grub_loader_cmdline_size (argc, argv);
|
||||||
len += grub_strlen (argv[i]) + 1;
|
|
||||||
if (len == 0)
|
|
||||||
len = 1;
|
|
||||||
|
|
||||||
cmdline = p = grub_malloc (len);
|
cmdline = grub_malloc (len);
|
||||||
if (! cmdline)
|
if (! cmdline)
|
||||||
return grub_errno;
|
return grub_errno;
|
||||||
cmdline_size = len;
|
cmdline_size = len;
|
||||||
|
|
||||||
for (i = 0; i < argc; i++)
|
grub_create_loader_cmdline (argc, argv, cmdline,
|
||||||
{
|
cmdline_size);
|
||||||
p = grub_stpcpy (p, argv[i]);
|
|
||||||
*(p++) = ' ';
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Remove the space after the last word. */
|
|
||||||
if (p != cmdline)
|
|
||||||
p--;
|
|
||||||
*p = '\0';
|
|
||||||
|
|
||||||
return GRUB_ERR_NONE;
|
return GRUB_ERR_NONE;
|
||||||
}
|
}
|
||||||
|
@ -939,9 +927,7 @@ grub_multiboot_add_module (grub_addr_t start, grub_size_t size,
|
||||||
int argc, char *argv[])
|
int argc, char *argv[])
|
||||||
{
|
{
|
||||||
struct module *newmod;
|
struct module *newmod;
|
||||||
char *p;
|
grub_size_t len = 0;
|
||||||
grub_ssize_t len = 0;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
newmod = grub_malloc (sizeof (*newmod));
|
newmod = grub_malloc (sizeof (*newmod));
|
||||||
if (!newmod)
|
if (!newmod)
|
||||||
|
@ -949,13 +935,9 @@ grub_multiboot_add_module (grub_addr_t start, grub_size_t size,
|
||||||
newmod->start = start;
|
newmod->start = start;
|
||||||
newmod->size = size;
|
newmod->size = size;
|
||||||
|
|
||||||
for (i = 0; i < argc; i++)
|
len = grub_loader_cmdline_size (argc, argv);
|
||||||
len += grub_strlen (argv[i]) + 1;
|
|
||||||
|
|
||||||
if (len == 0)
|
newmod->cmdline = grub_malloc (len);
|
||||||
len = 1;
|
|
||||||
|
|
||||||
newmod->cmdline = p = grub_malloc (len);
|
|
||||||
if (! newmod->cmdline)
|
if (! newmod->cmdline)
|
||||||
{
|
{
|
||||||
grub_free (newmod);
|
grub_free (newmod);
|
||||||
|
@ -964,16 +946,8 @@ grub_multiboot_add_module (grub_addr_t start, grub_size_t size,
|
||||||
newmod->cmdline_size = len;
|
newmod->cmdline_size = len;
|
||||||
total_modcmd += ALIGN_UP (len, MULTIBOOT_TAG_ALIGN);
|
total_modcmd += ALIGN_UP (len, MULTIBOOT_TAG_ALIGN);
|
||||||
|
|
||||||
for (i = 0; i < argc; i++)
|
grub_create_loader_cmdline (argc, argv, newmod->cmdline,
|
||||||
{
|
newmod->cmdline_size);
|
||||||
p = grub_stpcpy (p, argv[i]);
|
|
||||||
*(p++) = ' ';
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Remove the space after the last word. */
|
|
||||||
if (p != newmod->cmdline)
|
|
||||||
p--;
|
|
||||||
*p = '\0';
|
|
||||||
|
|
||||||
if (modules_last)
|
if (modules_last)
|
||||||
modules_last->next = newmod;
|
modules_last->next = newmod;
|
||||||
|
|
Loading…
Reference in a new issue