From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1YMN2T-0002WD-36 for mharc-grub-devel@gnu.org; Fri, 13 Feb 2015 15:40:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39200) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YMN2Q-0002W4-MV for grub-devel@gnu.org; Fri, 13 Feb 2015 15:40:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YMN2N-00044p-U0 for grub-devel@gnu.org; Fri, 13 Feb 2015 15:40:34 -0500 Received: from mail-lb0-x236.google.com ([2a00:1450:4010:c04::236]:43236) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YMN2N-00044O-DZ for grub-devel@gnu.org; Fri, 13 Feb 2015 15:40:31 -0500 Received: by mail-lb0-f182.google.com with SMTP id f15so16882975lbj.13 for ; Fri, 13 Feb 2015 12:40:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-type; bh=gVmiDPKsLHWphmhtpGkd3K4ACc+8cvwqHr5XNgxw680=; b=csqbGs7UL6nwe3+WtYXhTID9Wpy3XGWoy2G1YDchreUOzoSZl3eyQMjLRakhEpRLJT A4Jvps+7YTffvmuZVu5i8RqddxvBVjjINKZLHrdNRC0XGNTWIxWtFjF0DEZXuub4cigs y7Q9Ljf9Du2JKE2Wqvnbs0G3KcV4HdmFDchdonCjjN46YJ6RjVrRpCHRL0mdbsRH6Eo5 WGHY4WioUrYFd1VSf25j3mV1n2n8dA9DdSXHxURLzwktX+gwRy3F7jgPVZXZ3pTVNFOj 1+PAXzr+zuvXNYhY+4aj80/KHHI3QIrONXbKFzjelUgFwrNicraSe3Os9K39lbJm1UKc 4yfw== X-Received: by 10.152.28.129 with SMTP id b1mr9892687lah.37.1423860030416; Fri, 13 Feb 2015 12:40:30 -0800 (PST) Received: from opensuse.site (ppp91-76-14-38.pppoe.mtu-net.ru. [91.76.14.38]) by mx.google.com with ESMTPSA id b6sm1546774laa.14.2015.02.13.12.40.28 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Feb 2015 12:40:29 -0800 (PST) Date: Fri, 13 Feb 2015 23:40:24 +0300 From: Andrei Borzenkov To: Lunar Subject: Re: [bug #44238] Add support for menu.c32 and vesamenu.c32 in lib/syslinux_parse Message-ID: <20150213234024.48b03da1@opensuse.site> In-Reply-To: <20150213202023.GF688@loar> References: <20150213-163409.sv98365.64186@savannah.gnu.org> <20150213-190108.sv89796.21318@savannah.gnu.org> <20150213202023.GF688@loar> X-Mailer: Claws Mail 3.11.0 (GTK+ 2.24.25; x86_64-suse-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; boundary="Sig_/cKtoee7bL2HoXohdXnr6ebh"; protocol="application/pgp-signature" X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c04::236 Cc: grub-devel@gnu.org 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:40:36 -0000 --Sig_/cKtoee7bL2HoXohdXnr6ebh Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable =D0=92 Fri, 13 Feb 2015 21:20:23 +0100 Lunar =D0=BF=D0=B8=D1=88=D0=B5=D1=82: > From 9b441e5e6c602c71e522c594ca6cff72a12c078c Mon Sep 17 00:00:00 2001 > From: Lunar > Date: Sat, 14 Feb 2015 14:14:25 +0100 > Subject: [PATCH 1/2] lib/syslinux_parse: add support for (vesa)menu.c32 >=20 > Fixes Savannah bug #44238. > --- > grub-core/lib/syslinux_parse.c | 157 ++++++++++++++++++++++++++---------= ------ > 1 file changed, 99 insertions(+), 58 deletions(-) >=20 > diff --git a/grub-core/lib/syslinux_parse.c b/grub-core/lib/syslinux_pars= e.c > index 2c874b1..b0d5f9e 100644 > --- a/grub-core/lib/syslinux_parse.c > +++ b/grub-core/lib/syslinux_parse.c > @@ -840,6 +840,74 @@ simplify_filename (char *str) > } > =20 > static grub_err_t > +print_config (struct output_buffer *outbuf, > + struct syslinux_menu *menu, > + const char *filename, const char *basedir) > +{ > + grub_err_t err; > + char *new_cwd, *new_target_cwd; > + > + new_cwd =3D get_read_filename (menu, basedir); > + if (!new_cwd) > + return grub_errno; > + new_target_cwd =3D get_target_filename (menu, basedir); > + if (!new_target_cwd) > + return grub_errno; > + Memory leak. > + struct syslinux_menu *menuptr; > + char *newname; > + int depth =3D 0; > + If you move code anyway, please move declarations to the beginning. > + newname =3D get_read_filename (menu, filename); > + if (!newname) > + return grub_errno; Memory leak. > + simplify_filename (newname); > + > + print_string ("#"); > + print_file (outbuf, menu, filename, NULL); > + print_string (" "); > + print (outbuf, newname, grub_strlen (newname)); > + print_string (":\n"); > + > + for (menuptr =3D menu; menuptr; menuptr =3D menuptr->parent, depth++) > + if (grub_strcmp (menuptr->filename, newname) =3D=3D 0 > + || depth > 20) > + break; > + if (menuptr) > + { > + print_string (" syslinux_configfile -r "); > + print_file (outbuf, menu, "/", NULL); > + print_string (" -c "); > + print_file (outbuf, menu, basedir, NULL); > + print_string (" "); > + print_file (outbuf, menu, filename, NULL); > + print_string ("\n"); > + } > + else > + { > + err =3D config_file (outbuf, menu->root_read_directory, > + menu->root_target_directory, new_cwd, new_targe= t_cwd, > + newname, menu, menu->flavour); > + if (err =3D=3D GRUB_ERR_FILE_NOT_FOUND > + || err =3D=3D GRUB_ERR_BAD_FILENAME) > + { > + grub_errno =3D err =3D GRUB_ERR_NONE; > + print_string ("# File "); > + err =3D print (outbuf, newname, grub_strlen (newname)); > + if (err) > + return err; Memory leak. > + print_string (" not found\n"); > + } > + if (err) > + return err; Memory leak. > + } Just use goto and free them all here. I understand that you just move existing code but let's also fix them. > + grub_free (newname); > + grub_free (new_cwd); > + grub_free (new_target_cwd); > + return GRUB_ERR_NONE; > +} > + > +static grub_err_t > write_entry (struct output_buffer *outbuf, > struct syslinux_menu *menu, > struct syslinux_menuentry *curentry) > @@ -1240,6 +1308,36 @@ write_entry (struct output_buffer *outbuf, > break; > } > =20 > + if (grub_strcasecmp (basename, "menu.c32") =3D=3D 0 || > + grub_strcasecmp (basename, "vesamenu.c32") =3D=3D 0) > + { > + char *ptr; > + char *end; > + > + ptr =3D curentry->append; > + if (!ptr) > + return grub_errno; > + > + while (*ptr) > + { > + end =3D ptr; > + for (end =3D ptr; *end && !grub_isspace (*end); end++); > + if (*end) > + *end++ =3D '\0'; > + > + /* "~" is supposed to be current file, so let's skip it */ > + if (grub_strcmp (ptr, "~") !=3D 0) > + { > + err =3D print_config (outbuf, menu, ptr, ""); > + if (err !=3D GRUB_ERR_NONE) > + break; > + } > + for (ptr =3D end; *ptr && grub_isspace (*ptr); ptr++); > + } > + err =3D GRUB_ERR_NONE; > + break; > + } > + > /* FIXME: gdb, GFXBoot, Hdt, Ifcpu, Ifplop, Kbdmap, > FIXME: Linux, Lua, Meminfo, rosh, Sanbboot */ > =20 > @@ -1252,70 +1350,13 @@ write_entry (struct output_buffer *outbuf, > } > case KERNEL_CONFIG: > { > - char *new_cwd, *new_target_cwd; > const char *ap; > ap =3D curentry->append; > if (!ap) > ap =3D curentry->argument; > if (!ap) > ap =3D ""; > - new_cwd =3D get_read_filename (menu, ap); > - if (!new_cwd) > - return grub_errno; > - new_target_cwd =3D get_target_filename (menu, ap); > - if (!new_target_cwd) > - return grub_errno; > - > - struct syslinux_menu *menuptr; > - char *newname; > - int depth =3D 0; > -=09 > - newname =3D get_read_filename (menu, curentry->kernel_file); > - if (!newname) > - return grub_errno; > - simplify_filename (newname); > - > - print_string ("#"); > - print_file (outbuf, menu, curentry->kernel_file, NULL); > - print_string (" "); > - print (outbuf, newname, grub_strlen (newname)); > - print_string (":\n"); > - > - for (menuptr =3D menu; menuptr; menuptr =3D menuptr->parent, depth++) > - if (grub_strcmp (menuptr->filename, newname) =3D=3D 0 > - || depth > 20) > - break; > - if (menuptr) > - { > - print_string (" syslinux_configfile -r "); > - print_file (outbuf, menu, "/", NULL); > - print_string (" -c "); > - print_file (outbuf, menu, ap, NULL); > - print_string (" "); > - print_file (outbuf, menu, curentry->kernel_file, NULL); > - print_string ("\n"); > - } > - else > - { > - err =3D config_file (outbuf, menu->root_read_directory, > - menu->root_target_directory, new_cwd, new_target_cwd, > - newname, menu, menu->flavour); > - if (err =3D=3D GRUB_ERR_FILE_NOT_FOUND > - || err =3D=3D GRUB_ERR_BAD_FILENAME) > - { > - grub_errno =3D err =3D GRUB_ERR_NONE; > - print_string ("# File "); > - err =3D print (outbuf, newname, grub_strlen (newname)); > - if (err) > - return err; > - print_string (" not found\n"); > - } > - if (err) > - return err; > - } > - grub_free (newname); > - grub_free (new_cwd); > - grub_free (new_target_cwd); > + print_config (outbuf, menu, curentry->kernel_file, ap); > } > break; > case KERNEL_NO_KERNEL: --Sig_/cKtoee7bL2HoXohdXnr6ebh Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iEYEARECAAYFAlTeYTsACgkQR6LMutpd94zBfQCfYZ8TGgADJM73dHbIE2DoVTnA mTQAoJsKngDnz5PsiCSbWXmxERB8FrsU =piit -----END PGP SIGNATURE----- --Sig_/cKtoee7bL2HoXohdXnr6ebh--