mirror of
https://src.fedoraproject.org/rpms/grub2.git
synced 2024-12-01 00:48:18 +00:00
PPC - Handle device paths with commas correctly.
This commit is contained in:
parent
8205bedc55
commit
81324d0fad
2 changed files with 120 additions and 1 deletions
115
grub-2.00-ppc_handle_devices_with_comma.patch
Normal file
115
grub-2.00-ppc_handle_devices_with_comma.patch
Normal file
|
@ -0,0 +1,115 @@
|
|||
From 741d77171bd6ea971a98bdd6c78acb8f153ee896 Mon Sep 17 00:00:00 2001
|
||||
From: Fedora Ninjas <pjones@fedoraproject.org>
|
||||
Date: Wed, 23 Jul 2012 19:33:50 -0300
|
||||
Subject: [PATCH] Handle deives with comma in the name
|
||||
|
||||
---
|
||||
grub-core/disk/ieee1275/ofdisk.c | 15 +++++++++++----
|
||||
grub-core/kern/ieee1275/openfw.c | 27 ++++++++++++++++++++++++---
|
||||
grub-core/kern/main.c | 14 ++++++++++++--
|
||||
3 files changed, 47 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/grub-core/disk/ieee1275/ofdisk.c b/grub-core/disk/ieee1275/ofdisk.c
|
||||
index b5bb713..3280ead 100644
|
||||
--- a/grub-core/disk/ieee1275/ofdisk.c
|
||||
+++ b/grub-core/disk/ieee1275/ofdisk.c
|
||||
@@ -265,10 +265,17 @@ grub_ofdisk_iterate (int (*hook) (const char *name),
|
||||
continue;
|
||||
|
||||
{
|
||||
- char buffer[sizeof ("ieee1275/") + grub_strlen (ent->shortest)];
|
||||
- char *ptr;
|
||||
- ptr = grub_stpcpy (buffer, "ieee1275/");
|
||||
- grub_strcpy (ptr, ent->shortest);
|
||||
+ char buffer[sizeof ("ieee1275/") + 2 * grub_strlen (ent->shortest)];
|
||||
+ const char *iptr;
|
||||
+ char *optr;
|
||||
+ optr = grub_stpcpy (buffer, "ieee1275/");
|
||||
+ for (iptr = ent->shortest; *iptr; )
|
||||
+ {
|
||||
+ if (*iptr == ',')
|
||||
+ *optr++ = '\\';
|
||||
+ *optr++ = *iptr++;
|
||||
+ }
|
||||
+ *optr = 0;
|
||||
if (hook (buffer))
|
||||
return 1;
|
||||
}
|
||||
diff --git a/grub-core/kern/ieee1275/openfw.c b/grub-core/kern/ieee1275/openfw.c
|
||||
index caf820d..a23bb60 100644
|
||||
--- a/grub-core/kern/ieee1275/openfw.c
|
||||
+++ b/grub-core/kern/ieee1275/openfw.c
|
||||
@@ -439,21 +439,42 @@ char *
|
||||
grub_ieee1275_encode_devname (const char *path)
|
||||
{
|
||||
char *device = grub_ieee1275_get_devname (path);
|
||||
- char *partition = grub_ieee1275_parse_args (path, GRUB_PARSE_PARTITION);
|
||||
+ char *partition;
|
||||
char *encoding;
|
||||
+ char *optr;
|
||||
+ const char *iptr;
|
||||
|
||||
+ encoding = grub_malloc (sizeof ("ieee1275/") + 2 * grub_strlen (device)
|
||||
+ + sizeof (",XXXXXXXXXXXX"));
|
||||
+ if (!encoding)
|
||||
+ {
|
||||
+ grub_free (device);
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ partition = grub_ieee1275_parse_args (path, GRUB_PARSE_PARTITION);
|
||||
+
|
||||
+ optr = grub_stpcpy (encoding, "ieee1275/");
|
||||
+ for (iptr = device; *iptr; )
|
||||
+ {
|
||||
+ if (*iptr == ',')
|
||||
+ *optr++ ='\\';
|
||||
+ *optr++ = *iptr++;
|
||||
+ }
|
||||
if (partition && partition[0])
|
||||
{
|
||||
unsigned int partno = grub_strtoul (partition, 0, 0);
|
||||
|
||||
+ *optr++ = ',';
|
||||
+
|
||||
if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_0_BASED_PARTITIONS))
|
||||
/* GRUB partition 1 is OF partition 0. */
|
||||
partno++;
|
||||
|
||||
- encoding = grub_xasprintf ("ieee1275/%s,%d", device, partno);
|
||||
+ grub_snprintf (optr, sizeof ("XXXXXXXXXXXX"), "%d", partno);
|
||||
}
|
||||
else
|
||||
- encoding = grub_xasprintf ("ieee1275/%s", device);
|
||||
+ *optr = '\0';
|
||||
|
||||
grub_free (partition);
|
||||
grub_free (device);
|
||||
diff --git a/grub-core/kern/main.c b/grub-core/kern/main.c
|
||||
index 7a386d0..c05ac11 100644
|
||||
--- a/grub-core/kern/main.c
|
||||
+++ b/grub-core/kern/main.c
|
||||
@@ -153,8 +153,18 @@ grub_set_prefix_and_root (void)
|
||||
/* We have a partition, but still need to fill in the drive. */
|
||||
char *comma, *new_device;
|
||||
|
||||
- comma = grub_strchr (fwdevice, ',');
|
||||
- if (comma)
|
||||
+ for (comma = fwdevice; *comma; )
|
||||
+ {
|
||||
+ if (comma[0] == '\\' && comma[1] == ',')
|
||||
+ {
|
||||
+ comma += 2;
|
||||
+ continue;
|
||||
+ }
|
||||
+ if (*comma == ',')
|
||||
+ break;
|
||||
+ comma++;
|
||||
+ }
|
||||
+ if (*comma)
|
||||
{
|
||||
char *drive = grub_strndup (fwdevice, comma - fwdevice);
|
||||
new_device = grub_xasprintf ("%s%s", drive, device);
|
||||
--
|
||||
1.7.10.4
|
||||
|
|
@ -39,7 +39,7 @@
|
|||
Name: grub2
|
||||
Epoch: 1
|
||||
Version: 2.0
|
||||
Release: 0.37.beta6%{?dist}
|
||||
Release: 0.38.beta6%{?dist}
|
||||
Summary: Bootloader with support for Linux, Multiboot and more
|
||||
|
||||
Group: System Environment/Base
|
||||
|
@ -64,6 +64,7 @@ Patch17: grub-2.00-ppc-hints.patch
|
|||
Patch18: grub-2.00-support-vscsi-on-ibm-ppc.patch
|
||||
Patch19: grub-2.00-ppc-usb-quiesce.patch
|
||||
Patch20: grub-2.00-no-double-free.patch
|
||||
Patch21: grub-2.00-ppc_handle_devices_with_comma.patch
|
||||
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||
|
||||
|
@ -389,6 +390,9 @@ fi
|
|||
%doc grub-%{tarversion}/themes/starfield/COPYING.CC-BY-SA-3.0
|
||||
|
||||
%changelog
|
||||
* Thu Aug 02 2012 Peter Jones <pjones@redhat.com> - 2.0-0.38.beta6
|
||||
- PPC - Handle device paths with commas correctly.
|
||||
|
||||
* Mon Jun 18 2012 Peter Jones <pjones@redhat.com> - 2.0-0.37.beta6
|
||||
- Fix double-free in grub-probe.
|
||||
|
||||
|
|
Loading…
Reference in a new issue