From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1YMMum-0008H5-Cs for mharc-grub-devel@gnu.org; Fri, 13 Feb 2015 15:32:40 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38185) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YMMuj-0008Gz-Rs for grub-devel@gnu.org; Fri, 13 Feb 2015 15:32:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YMMug-0007Rj-Qc for grub-devel@gnu.org; Fri, 13 Feb 2015 15:32:37 -0500 Received: from poivron.org ([91.194.60.101]:48951 helo=mail.poivron.org) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YMMug-0007Re-HU for grub-devel@gnu.org; Fri, 13 Feb 2015 15:32:34 -0500 Received: from [127.0.0.1] (localhost [127.0.0.1]) with ESMTPSA id 161EAC09F9E Date: Fri, 13 Feb 2015 21:32:32 +0100 From: Lunar To: grub-devel@gnu.org Subject: Re: [bug #44239] Behavior of syslinux_parse differs from SYSLINUX for initrd= option Message-ID: <20150213203232.GG688@loar> References: <20150213-163645.sv98365.99674@savannah.gnu.org> <20150213-191419.sv89796.29507@savannah.gnu.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="5cSRzy0VGBWAML+b" Content-Disposition: inline In-Reply-To: <20150213-191419.sv89796.29507@savannah.gnu.org> User-Agent: Mutt/1.5.23 (2014-03-12) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 91.194.60.101 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Feb 2015 20:32:39 -0000 --5cSRzy0VGBWAML+b Content-Type: multipart/mixed; boundary="fmvA4kSBHQVZhkR6" Content-Disposition: inline --fmvA4kSBHQVZhkR6 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Andrei Borzenkov: > Follow-up Comment #1, bug #44239 (project grub): >=20 > Can't comment about behavior itself. Re. patch >=20 > + cmdline =3D grub_strdup(curentry->append); > Error check missing. >=20 > + 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. --=20 Lunar --fmvA4kSBHQVZhkR6 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: inline; filename="0002-lib-syslinux_parse-keep-initrd-in-kernel-the-command.patch" Content-Transfer-Encoding: quoted-printable =46rom d1a88855eea4b2b3099d8ad8ff689305f74736cd Mon Sep 17 00:00:00 2001 =46rom: Lunar Date: Sat, 14 Feb 2015 16:50:14 +0100 Subject: [PATCH 2/2] lib/syslinux_parse: keep initrd=3D in kernel the comma= nd line SYSLINUX parses but does not remove "initrd=3D..." 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 =3D NULL; + cmdline =3D grub_strdup(curentry->append ? curentry->append : ""); + if (!cmdline) + return grub_errno; for (ptr =3D curentry->append; ptr && *ptr; ptr++) if ((ptr =3D=3D curentry->append || grub_isspace (ptr[-1])) && grub_strncasecmp (ptr, "initrd=3D", sizeof ("initrd=3D") - 1) @@ -946,32 +949,16 @@ write_entry (struct output_buffer *outbuf, break; if (ptr && *ptr) { - char *ptr2; - grub_size_t totlen =3D grub_strlen (curentry->append); initrd =3D ptr + sizeof ("initrd=3D") - 1; - for (ptr2 =3D ptr; *ptr2 && !grub_isspace (*ptr2); ptr2++); - if (*ptr2) - { - *ptr2 =3D 0; - ptr2++; - } - cmdline =3D 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)) =3D 0; + for (; *ptr && !grub_isspace (*ptr); ptr++); + *ptr =3D '\0'; } - else - cmdline =3D curentry->append; print_string (" if test x$grub_platform =3D xpc; then " "linux_suffix=3D16; else linux_suffix=3D ; 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, =20 print_string ("\n"); } - if (ptr && *ptr) - grub_free (cmdline); + grub_free (cmdline); } break; case KERNEL_CHAINLOADER: --=20 1.9.1 --fmvA4kSBHQVZhkR6-- --5cSRzy0VGBWAML+b Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJU3l9TAAoJEEAsIlA9Nuk2avoQAJAyYqGGOqHpKI75s0Utuess fwxlSFnqNxBPBcaJpikr2raHrNfAiqIQ7ncqKWrHKgJA0Fbj3goE8HZUM5MP4vE+ Na/omCq4gFgynLBWBNYuwsraKr96OfxmCZnaNFHJbX2G5qSN0XKKTCa9xY+B0jZD pHDalQoS5o4T7XlKvQ+vclVapxx2XAih8fgH2MvNcwx10tUMIfn5QUdX0UIR3FJg OLBwxOnKjWkwphWLLgoKK2DZVmBSj3FAlojjvSio5B3yAoCg9H7St/dBwC9/eH91 geH+nBiuHASQlCwbZwb3OHiLx0GR3JorOidHLHMmFDBfhLVQ8zGmUVmDLeSLOb3e JbLlT5udcbeTL7j6C/eylK7RPnpC8321ta74Nq5vvB5mqMMIWlSHe33eOkHO+m3O kG0YZISl+EscYFH9zwCE3+CTg3TNFzjxuythyPJYAY6S41xZID2DPDSVAOOtGzMY DrnaF100erPOUB+1FvQtI7wUANQCBZOay6+wI3eRlFI2v49zwMu125jWrKi3ML8Y Hmi+ewRMVkETfx6MT1oaCTNw69kA0SGtR+D9yDHtG9OR4Cf7JD8+ryx9hLyFG7z5 9Ii7fGuIpmFfHq08aczYyPxVkxT392Q5ljyM3r1jl/bu3hvSjYH23HNcx7g7aNqH pwX8CGOdOaqj5HcdtUbX =MWFF -----END PGP SIGNATURE----- --5cSRzy0VGBWAML+b--