* util/grub.d/30_os-prober.in: Fix occurence of grub-probe instead of

grub_probe.
	Reported by: adamwill
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2012-01-13 13:54:24 +01:00
parent 7e532280bd
commit 3c76ea0c2c
8 changed files with 187 additions and 77 deletions

View file

@ -1,3 +1,9 @@
2012-01-13 Vladimir Serbinenko <phcoder@gmail.com>
* util/grub.d/30_os-prober.in: Fix occurence of grub-probe instead of
grub_probe.
Reported by: adamwill
2012-01-12 Seth Goldberg <seth.goldberg@oracle.com>
* grub-core/lib/arg.c (grub_arg_parse): Fix NULL pointer dereference.

View file

@ -941,12 +941,15 @@ static grub_err_t
grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
int argc, char *argv[])
{
grub_file_t file = 0;
grub_ssize_t size;
grub_file_t *files = 0;
grub_size_t size = 0;
grub_addr_t addr_min, addr_max;
grub_addr_t addr;
grub_err_t err;
struct linux_kernel_header *lh;
int i;
int nfiles = 0;
grub_uint8_t *ptr;
if (argc == 0)
{
@ -960,12 +963,20 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
goto fail;
}
grub_file_filter_disable_compression ();
file = grub_file_open (argv[0]);
if (! file)
files = grub_zalloc (argc * sizeof (files[0]));
if (!files)
goto fail;
size = grub_file_size (file);
for (i = 0; i < argc; i++)
{
grub_file_filter_disable_compression ();
files[i] = grub_file_open (argv[i]);
if (! files[i])
goto fail;
nfiles++;
size += grub_file_size (files[i]);
}
initrd_pages = (page_align (size) >> 12);
lh = (struct linux_kernel_header *) real_mode_mem;
@ -1017,12 +1028,18 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
initrd_mem_target = get_physical_target_address (ch);
}
if (grub_file_read (file, initrd_mem, size) != size)
ptr = initrd_mem;
for (i = 0; i < nfiles; i++)
{
if (!grub_errno)
grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"),
argv[0]);
goto fail;
grub_ssize_t cursize = grub_file_size (files[i]);
if (grub_file_read (files[i], ptr, cursize) != cursize)
{
if (!grub_errno)
grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"),
argv[i]);
goto fail;
}
ptr += cursize;
}
grub_dprintf ("linux", "Initrd, addr=0x%x, size=0x%x\n",
@ -1033,8 +1050,9 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
lh->root_dev = 0x0100; /* XXX */
fail:
if (file)
grub_file_close (file);
for (i = 0; i < nfiles; i++)
grub_file_close (files[i]);
grub_free (files);
return grub_errno;
}

View file

@ -354,13 +354,15 @@ static grub_err_t
grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
int argc, char *argv[])
{
grub_file_t file = 0;
grub_ssize_t size;
grub_file_t *files = 0;
grub_size_t size = 0;
grub_addr_t addr_max, addr_min;
struct linux_kernel_header *lh;
grub_uint8_t *initrd_chunk;
grub_addr_t initrd_addr;
grub_err_t err;
int i, nfiles = 0;
grub_uint8_t *ptr;
if (argc == 0)
{
@ -408,12 +410,19 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
addr_min = GRUB_LINUX_BZIMAGE_ADDR + grub_linux16_prot_size;
grub_file_filter_disable_compression ();
file = grub_file_open (argv[0]);
if (!file)
files = grub_zalloc (argc * sizeof (files[0]));
if (!files)
goto fail;
size = grub_file_size (file);
for (i = 0; i < argc; i++)
{
grub_file_filter_disable_compression ();
files[i] = grub_file_open (argv[i]);
if (! files[i])
goto fail;
nfiles++;
size += grub_file_size (files[i]);
}
{
grub_relocator_chunk_t ch;
@ -427,20 +436,28 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
initrd_addr = get_physical_target_address (ch);
}
if (grub_file_read (file, initrd_chunk, size) != size)
ptr = initrd_chunk;
for (i = 0; i < nfiles; i++)
{
if (!grub_errno)
grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"),
argv[0]);
goto fail;
grub_ssize_t cursize = grub_file_size (files[i]);
if (grub_file_read (files[i], ptr, cursize) != cursize)
{
if (!grub_errno)
grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"),
argv[i]);
goto fail;
}
ptr += cursize;
}
lh->ramdisk_image = initrd_addr;
lh->ramdisk_size = size;
fail:
if (file)
grub_file_close (file);
for (i = 0; i < nfiles; i++)
grub_file_close (files[i]);
grub_free (files);
return grub_errno;
}

View file

@ -583,7 +583,10 @@ static grub_err_t
grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
int argc, char *argv[])
{
grub_file_t file = 0;
grub_file_t *files = 0;
int i;
int nfiles = 0;
grub_uint8_t *ptr;
if (argc == 0)
{
@ -597,11 +600,23 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
goto fail;
}
file = grub_file_open (argv[0]);
if (! file)
files = grub_zalloc (argc * sizeof (files[0]));
if (!files)
goto fail;
grub_printf ("Loading initrd: %s\n",argv[0]);
initrd_size = 0;
grub_printf ("Loading initrd: ");
for (i = 0; i < argc; i++)
{
grub_file_filter_disable_compression ();
files[i] = grub_file_open (argv[i]);
if (! files[i])
goto fail;
nfiles++;
initrd_size += grub_file_size (files[i]);
grub_printf ("%c%s\n", i == 0 ? ' ' : '+', argv[i]);
}
grub_printf ("\n");
initrd_size = grub_file_size (file);
initrd_pages = (page_align (initrd_size) >> 12);
@ -612,17 +627,23 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
grub_printf (" [addr=0x%lx, size=0x%lx]\n",
(grub_uint64_t)initrd_mem, initrd_size);
if (grub_file_read (file, initrd_mem, initrd_size)
!= (grub_ssize_t) initrd_size)
ptr = initrd_mem;
for (i = 0; i < nfiles; i++)
{
if (!grub_errno)
grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"),
argv[0]);
goto fail;
grub_ssize_t cursize = grub_file_size (files[i]);
if (grub_file_read (files[i], ptr, cursize) != cursize)
{
if (!grub_errno)
grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"),
argv[i]);
goto fail;
}
ptr += cursize;
}
fail:
if (file)
grub_file_close (file);
for (i = 0; i < nfiles; i++)
grub_file_close (files[i]);
grub_free (files);
return grub_errno;
}

View file

@ -435,11 +435,14 @@ static grub_err_t
grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
int argc, char *argv[])
{
grub_file_t file = 0;
grub_ssize_t size;
grub_file_t *files = 0;
grub_size_t size = 0;
void *initrd_src;
grub_addr_t initrd_dest;
grub_err_t err;
int i;
int nfiles = 0;
grub_uint8_t *ptr;
if (argc == 0)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "no initrd specified");
@ -448,14 +451,21 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
return grub_error (GRUB_ERR_BAD_ARGUMENT, "you need to load Linux first.");
if (initrd_loaded)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "only one initrd can be loaded.");
return grub_error (GRUB_ERR_BAD_ARGUMENT, "only one initrd command can be issued.");
grub_file_filter_disable_compression ();
file = grub_file_open (argv[0]);
if (! file)
return grub_errno;
files = grub_zalloc (argc * sizeof (files[0]));
if (!files)
goto fail;
size = grub_file_size (file);
for (i = 0; i < argc; i++)
{
grub_file_filter_disable_compression ();
files[i] = grub_file_open (argv[i]);
if (! files[i])
goto fail;
nfiles++;
size += grub_file_size (files[i]);
}
{
grub_relocator_chunk_t ch;
@ -476,14 +486,18 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
initrd_dest = get_physical_target_address (ch) | 0x80000000;
}
if (grub_file_read (file, initrd_src, size) != size)
ptr = initrd_src;
for (i = 0; i < nfiles; i++)
{
if (!grub_errno)
grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"),
argv[0]);
grub_file_close (file);
return grub_errno;
grub_ssize_t cursize = grub_file_size (files[i]);
if (grub_file_read (files[i], ptr, cursize) != cursize)
{
if (!grub_errno)
grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"),
argv[i]);
goto fail;
}
ptr += cursize;
}
#ifdef GRUB_MACHINE_MIPS_QEMU_MIPS

View file

@ -317,10 +317,13 @@ static grub_err_t
grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
int argc, char *argv[])
{
grub_file_t file = 0;
grub_ssize_t size;
grub_file_t *files = 0;
grub_size_t size = 0;
grub_addr_t first_addr;
grub_addr_t addr;
int i;
int nfiles = 0;
grub_uint8_t *ptr;
if (argc == 0)
{
@ -334,13 +337,21 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
goto fail;
}
grub_file_filter_disable_compression ();
file = grub_file_open (argv[0]);
if (! file)
files = grub_zalloc (argc * sizeof (files[0]));
if (!files)
goto fail;
for (i = 0; i < argc; i++)
{
grub_file_filter_disable_compression ();
files[i] = grub_file_open (argv[i]);
if (! files[i])
goto fail;
nfiles++;
size += grub_file_size (files[i]);
}
first_addr = linux_addr + linux_size;
size = grub_file_size (file);
/* Attempt to claim at a series of addresses until successful in
the same way that grub_rescue_cmd_linux does. */
@ -350,13 +361,19 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
grub_dprintf ("loader", "Loading initrd at 0x%x, size 0x%x\n", addr, size);
if (grub_file_read (file, (void *) addr, size) != size)
ptr = (void *) addr;
for (i = 0; i < nfiles; i++)
{
grub_ieee1275_release (addr, size);
if (!grub_errno)
grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"),
argv[0]);
goto fail;
grub_ssize_t cursize = grub_file_size (files[i]);
if (grub_file_read (files[i], ptr, cursize) != cursize)
{
grub_ieee1275_release (addr, size);
if (!grub_errno)
grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"),
argv[i]);
goto fail;
}
ptr += cursize;
}
initrd_addr = addr;

View file

@ -371,11 +371,14 @@ static grub_err_t
grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
int argc, char *argv[])
{
grub_file_t file = 0;
grub_ssize_t size;
grub_file_t *files = 0;
grub_size_t size = 0;
grub_addr_t paddr;
grub_addr_t addr;
int ret;
int i;
int nfiles = 0;
grub_uint8_t *ptr;
if (argc == 0)
{
@ -389,13 +392,21 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
goto fail;
}
grub_file_filter_disable_compression ();
file = grub_file_open (argv[0]);
if (! file)
files = grub_zalloc (argc * sizeof (files[0]));
if (!files)
goto fail;
for (i = 0; i < argc; i++)
{
grub_file_filter_disable_compression ();
files[i] = grub_file_open (argv[i]);
if (! files[i])
goto fail;
nfiles++;
size += grub_file_size (files[i]);
}
addr = 0x60000000;
size = grub_file_size (file);
paddr = alloc_phys (size);
if (paddr == (grub_addr_t) -1)
@ -415,12 +426,18 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
grub_dprintf ("loader", "Loading initrd at vaddr 0x%lx, paddr 0x%lx, size 0x%lx\n",
addr, paddr, size);
if (grub_file_read (file, (void *) addr, size) != size)
ptr = (void *) addr;
for (i = 0; i < nfiles; i++)
{
if (!grub_errno)
grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"),
argv[0]);
goto fail;
grub_ssize_t cursize = grub_file_size (files[i]);
if (grub_file_read (files[i], ptr, cursize) != cursize)
{
if (!grub_errno)
grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"),
argv[i]);
goto fail;
}
ptr += cursize;
}
initrd_addr = addr;

View file

@ -168,7 +168,7 @@ EOF
done
;;
macosx)
OSXUUID="`grub-probe --target=fs_uuid --device ${DEVICE} 2> /dev/null`"
OSXUUID="`${grub_probe} --target=fs_uuid --device ${DEVICE} 2> /dev/null`"
osx_entry xnu_kernel 32
osx_entry xnu_kernel64 64
;;