View | Details | Raw Unified | Return to bug 32810
Collapse All | Expand All

(-)a/grub-core/Makefile.core.def (+2 lines)
Lines 1576-1581 module = { Link Here
1576
  cppflags = "-DGRUB_USE_MULTIBOOT2";
1576
  cppflags = "-DGRUB_USE_MULTIBOOT2";
1577
1577
1578
  common = loader/multiboot.c;
1578
  common = loader/multiboot.c;
1579
  common = lib/cmdline.c;
1579
  common = loader/multiboot_mbi2.c;
1580
  common = loader/multiboot_mbi2.c;
1580
  enable = x86;
1581
  enable = x86;
1581
  enable = mips;
1582
  enable = mips;
Lines 1584-1589 module = { Link Here
1584
module = {
1585
module = {
1585
  name = multiboot;
1586
  name = multiboot;
1586
  common = loader/multiboot.c;
1587
  common = loader/multiboot.c;
1588
  common = lib/cmdline.c;
1587
  x86 = loader/i386/multiboot_mbi.c;
1589
  x86 = loader/i386/multiboot_mbi.c;
1588
  extra_dist = loader/multiboot_elfxx.c;
1590
  extra_dist = loader/multiboot_elfxx.c;
1589
  enable = x86;
1591
  enable = x86;
(-)a/grub-core/loader/i386/multiboot_mbi.c (-40 / +11 lines)
Lines 35-40 Link Here
35
#include <grub/file.h>
35
#include <grub/file.h>
36
#include <grub/net.h>
36
#include <grub/net.h>
37
#include <grub/i18n.h>
37
#include <grub/i18n.h>
38
#include <grub/lib/cmdline.h>
38
39
39
#ifdef GRUB_MACHINE_EFI
40
#ifdef GRUB_MACHINE_EFI
40
#include <grub/efi/efi.h>
41
#include <grub/efi/efi.h>
Lines 641-671 grub_err_t Link Here
641
grub_multiboot_init_mbi (int argc, char *argv[])
642
grub_multiboot_init_mbi (int argc, char *argv[])
642
{
643
{
643
  grub_ssize_t len = 0;
644
  grub_ssize_t len = 0;
644
  char *p;
645
  int i;
646
645
647
  grub_multiboot_free_mbi ();
646
  grub_multiboot_free_mbi ();
648
647
649
  for (i = 0; i < argc; i++)
648
  len = grub_loader_cmdline_size (argc, argv);
650
    len += grub_strlen (argv[i]) + 1;
651
  if (len == 0)
652
    len = 1;
653
649
654
  cmdline = p = grub_malloc (len);
650
  cmdline = grub_malloc (len);
655
  if (! cmdline)
651
  if (! cmdline)
656
    return grub_errno;
652
    return grub_errno;
657
  cmdline_size = len;
653
  cmdline_size = len;
658
654
659
  for (i = 0; i < argc; i++)
655
  grub_create_loader_cmdline (argc, argv, cmdline,
660
    {
656
			      cmdline_size);
661
      p = grub_stpcpy (p, argv[i]);
662
      *(p++) = ' ';
663
    }
664
665
  /* Remove the space after the last word.  */
666
  if (p != cmdline)
667
    p--;
668
  *p = '\0';
669
657
670
  return GRUB_ERR_NONE;
658
  return GRUB_ERR_NONE;
671
}
659
}
Lines 675-683 grub_multiboot_add_module (grub_addr_t start, grub_size_t size, Link Here
675
			   int argc, char *argv[])
663
			   int argc, char *argv[])
676
{
664
{
677
  struct module *newmod;
665
  struct module *newmod;
678
  char *p;
666
  grub_size_t len = 0;
679
  grub_ssize_t len = 0;
680
  int i;
681
667
682
  newmod = grub_malloc (sizeof (*newmod));
668
  newmod = grub_malloc (sizeof (*newmod));
683
  if (!newmod)
669
  if (!newmod)
Lines 686-698 grub_multiboot_add_module (grub_addr_t start, grub_size_t size, Link Here
686
  newmod->size = size;
672
  newmod->size = size;
687
  newmod->next = 0;
673
  newmod->next = 0;
688
674
689
  for (i = 0; i < argc; i++)
675
  len = grub_loader_cmdline_size (argc, argv);
690
    len += grub_strlen (argv[i]) + 1;
691
692
  if (len == 0)
693
    len = 1;
694
676
695
  newmod->cmdline = p = grub_malloc (len);
677
  newmod->cmdline = grub_malloc (len);
696
  if (! newmod->cmdline)
678
  if (! newmod->cmdline)
697
    {
679
    {
698
      grub_free (newmod);
680
      grub_free (newmod);
Lines 701-724 grub_multiboot_add_module (grub_addr_t start, grub_size_t size, Link Here
701
  newmod->cmdline_size = len;
683
  newmod->cmdline_size = len;
702
  total_modcmd += ALIGN_UP (len, 4);
684
  total_modcmd += ALIGN_UP (len, 4);
703
685
704
  for (i = 0; i < argc; i++)
686
  grub_create_loader_cmdline (argc, argv, newmod->cmdline,
705
    {
687
			      newmod->cmdline_size);
706
      p = grub_stpcpy (p, argv[i]);
707
      *(p++) = ' ';
708
    }
709
710
  /* Remove the space after the last word.  */
711
  if (p != newmod->cmdline)
712
    p--;
713
  *p = '\0';
714
688
715
  if (modules_last)
689
  if (modules_last)
716
    modules_last->next = newmod;
690
    modules_last->next = newmod;
717
  else
691
  else
718
    {
692
    modules = newmod;
719
      modules = newmod;
720
      modules_last->next = NULL;
721
    }
722
  modules_last = newmod;
693
  modules_last = newmod;
723
694
724
  modcnt++;
695
  modcnt++;
(-)a/grub-core/loader/multiboot_mbi2.c (-36 / +11 lines)
Lines 35-40 Link Here
35
#include <grub/video.h>
35
#include <grub/video.h>
36
#include <grub/acpi.h>
36
#include <grub/acpi.h>
37
#include <grub/i18n.h>
37
#include <grub/i18n.h>
38
#include <grub/net.h>
39
#include <grub/lib/cmdline.h>
38
40
39
#if defined (GRUB_MACHINE_EFI)
41
#if defined (GRUB_MACHINE_EFI)
40
#include <grub/efi/efi.h>
42
#include <grub/efi/efi.h>
Lines 905-935 grub_err_t Link Here
905
grub_multiboot_init_mbi (int argc, char *argv[])
906
grub_multiboot_init_mbi (int argc, char *argv[])
906
{
907
{
907
  grub_ssize_t len = 0;
908
  grub_ssize_t len = 0;
908
  char *p;
909
  int i;
910
909
911
  grub_multiboot_free_mbi ();
910
  grub_multiboot_free_mbi ();
912
911
913
  for (i = 0; i < argc; i++)
912
  len = grub_loader_cmdline_size (argc, argv);
914
    len += grub_strlen (argv[i]) + 1;
915
  if (len == 0)
916
    len = 1;
917
913
918
  cmdline = p = grub_malloc (len);
914
  cmdline = grub_malloc (len);
919
  if (! cmdline)
915
  if (! cmdline)
920
    return grub_errno;
916
    return grub_errno;
921
  cmdline_size = len;
917
  cmdline_size = len;
922
918
923
  for (i = 0; i < argc; i++)
919
  grub_create_loader_cmdline (argc, argv, cmdline,
924
    {
920
			      cmdline_size);
925
      p = grub_stpcpy (p, argv[i]);
926
      *(p++) = ' ';
927
    }
928
929
  /* Remove the space after the last word.  */
930
  if (p != cmdline)
931
    p--;
932
  *p = '\0';
933
921
934
  return GRUB_ERR_NONE;
922
  return GRUB_ERR_NONE;
935
}
923
}
Lines 939-947 grub_multiboot_add_module (grub_addr_t start, grub_size_t size, Link Here
939
			   int argc, char *argv[])
927
			   int argc, char *argv[])
940
{
928
{
941
  struct module *newmod;
929
  struct module *newmod;
942
  char *p;
930
  grub_size_t len = 0;
943
  grub_ssize_t len = 0;
944
  int i;
945
931
946
  newmod = grub_malloc (sizeof (*newmod));
932
  newmod = grub_malloc (sizeof (*newmod));
947
  if (!newmod)
933
  if (!newmod)
Lines 949-961 grub_multiboot_add_module (grub_addr_t start, grub_size_t size, Link Here
949
  newmod->start = start;
935
  newmod->start = start;
950
  newmod->size = size;
936
  newmod->size = size;
951
937
952
  for (i = 0; i < argc; i++)
938
  len = grub_loader_cmdline_size (argc, argv);
953
    len += grub_strlen (argv[i]) + 1;
954
939
955
  if (len == 0)
940
  newmod->cmdline = grub_malloc (len);
956
    len = 1;
957
958
  newmod->cmdline = p = grub_malloc (len);
959
  if (! newmod->cmdline)
941
  if (! newmod->cmdline)
960
    {
942
    {
961
      grub_free (newmod);
943
      grub_free (newmod);
Lines 964-979 grub_multiboot_add_module (grub_addr_t start, grub_size_t size, Link Here
964
  newmod->cmdline_size = len;
946
  newmod->cmdline_size = len;
965
  total_modcmd += ALIGN_UP (len, MULTIBOOT_TAG_ALIGN);
947
  total_modcmd += ALIGN_UP (len, MULTIBOOT_TAG_ALIGN);
966
948
967
  for (i = 0; i < argc; i++)
949
  grub_create_loader_cmdline (argc, argv, newmod->cmdline,
968
    {
950
			      newmod->cmdline_size);
969
      p = grub_stpcpy (p, argv[i]);
970
      *(p++) = ' ';
971
    }
972
973
  /* Remove the space after the last word.  */
974
  if (p != newmod->cmdline)
975
    p--;
976
  *p = '\0';
977
951
978
  if (modules_last)
952
  if (modules_last)
979
    modules_last->next = newmod;
953
    modules_last->next = newmod;

Return to bug 32810