* Re: [bug #44239] Behavior of syslinux_parse differs from SYSLINUX for initrd= option
[not found] ` <20150213-191419.sv89796.29507@savannah.gnu.org>
@ 2015-02-13 20:32 ` Lunar
2015-02-16 15:07 ` Vladimir 'φ-coder/phcoder' Serbinenko
0 siblings, 1 reply; 2+ messages in thread
From: Lunar @ 2015-02-13 20:32 UTC (permalink / raw)
To: grub-devel
[-- Attachment #1.1: Type: text/plain, Size: 456 bytes --]
Andrei Borzenkov:
> Follow-up Comment #1, bug #44239 (project grub):
>
> Can't comment about behavior itself. Re. patch
>
> + cmdline = grub_strdup(curentry->append);
> Error check missing.
>
> + grub_free(cmdline);
> You need to delete free(cmdline) later.
Both fixed.
> Again, can you post updated version to grub-devel for easier review?
Here it is.
--
Lunar <lunar@torproject.org>
[-- Attachment #1.2: 0002-lib-syslinux_parse-keep-initrd-in-kernel-the-command.patch --]
[-- Type: text/x-diff, Size: 2644 bytes --]
From d1a88855eea4b2b3099d8ad8ff689305f74736cd Mon Sep 17 00:00:00 2001
From: Lunar <lunar@torproject.org>
Date: Sat, 14 Feb 2015 16:50:14 +0100
Subject: [PATCH 2/2] lib/syslinux_parse: keep initrd= in kernel the command
line
SYSLINUX parses but does not remove "initrd=..." option from the kernel
command line. As some distributions (e.g. Tails) rely on its
presence, let's keep the same behavior.
Fixes Savannah bug #44239.
---
grub-core/lib/syslinux_parse.c | 28 +++++++---------------------
1 file changed, 7 insertions(+), 21 deletions(-)
diff --git a/grub-core/lib/syslinux_parse.c b/grub-core/lib/syslinux_parse.c
index b0d5f9e..1318c3a 100644
--- a/grub-core/lib/syslinux_parse.c
+++ b/grub-core/lib/syslinux_parse.c
@@ -939,6 +939,9 @@ write_entry (struct output_buffer *outbuf,
char *ptr;
char *cmdline;
char *initrd = NULL;
+ cmdline = grub_strdup(curentry->append ? curentry->append : "");
+ if (!cmdline)
+ return grub_errno;
for (ptr = curentry->append; ptr && *ptr; ptr++)
if ((ptr == curentry->append || grub_isspace (ptr[-1]))
&& grub_strncasecmp (ptr, "initrd=", sizeof ("initrd=") - 1)
@@ -946,32 +949,16 @@ write_entry (struct output_buffer *outbuf,
break;
if (ptr && *ptr)
{
- char *ptr2;
- grub_size_t totlen = grub_strlen (curentry->append);
initrd = ptr + sizeof ("initrd=") - 1;
- 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;
- grub_memcpy (cmdline, curentry->append, ptr - curentry->append);
- grub_memcpy (cmdline + (ptr - curentry->append),
- ptr2, totlen - (ptr2 - curentry->append));
- *(cmdline + totlen - (ptr2 - ptr)) = 0;
+ for (; *ptr && !grub_isspace (*ptr); ptr++);
+ *ptr = '\0';
}
- else
- cmdline = curentry->append;
print_string (" if test x$grub_platform = xpc; then "
"linux_suffix=16; else linux_suffix= ; fi\n");
print_string (" linux$linux_suffix ");
print_file (outbuf, menu, curentry->kernel_file, NULL);
print_string (" ");
- if (cmdline)
- print (outbuf, cmdline, grub_strlen (cmdline));
+ print (outbuf, cmdline, grub_strlen (cmdline));
print_string ("\n");
if (initrd || curentry->initrds)
{
@@ -990,8 +977,7 @@ write_entry (struct output_buffer *outbuf,
print_string ("\n");
}
- if (ptr && *ptr)
- grub_free (cmdline);
+ grub_free (cmdline);
}
break;
case KERNEL_CHAINLOADER:
--
1.9.1
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [bug #44239] Behavior of syslinux_parse differs from SYSLINUX for initrd= option
2015-02-13 20:32 ` [bug #44239] Behavior of syslinux_parse differs from SYSLINUX for initrd= option Lunar
@ 2015-02-16 15:07 ` Vladimir 'φ-coder/phcoder' Serbinenko
0 siblings, 0 replies; 2+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2015-02-16 15:07 UTC (permalink / raw)
To: The development of GNU GRUB
[-- Attachment #1: Type: text/plain, Size: 725 bytes --]
On 13.02.2015 21:32, Lunar wrote:
> Andrei Borzenkov:
>> Follow-up Comment #1, bug #44239 (project grub):
>>
>> Can't comment about behavior itself. Re. patch
>>
>> + cmdline = grub_strdup(curentry->append);
>> Error check missing.
>>
>> + grub_free(cmdline);
>> You need to delete free(cmdline) later.
>
> Both fixed.
>
>> Again, can you post updated version to grub-devel for easier review?
>
> Here it is.
>
The code at this place turned out to be not very understandable. I
simplified the code and did the change you requested.
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 213 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-02-16 15:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20150213-163645.sv98365.99674@savannah.gnu.org>
[not found] ` <20150213-191419.sv89796.29507@savannah.gnu.org>
2015-02-13 20:32 ` [bug #44239] Behavior of syslinux_parse differs from SYSLINUX for initrd= option Lunar
2015-02-16 15:07 ` Vladimir 'φ-coder/phcoder' Serbinenko
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.