From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1NgRzA-000602-B7 for mharc-grub-devel@gnu.org; Sat, 13 Feb 2010 19:05:16 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NgRz9-0005zf-KY for grub-devel@gnu.org; Sat, 13 Feb 2010 19:05:15 -0500 Received: from [140.186.70.92] (port=33729 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NgRz9-0005zV-0v for grub-devel@gnu.org; Sat, 13 Feb 2010 19:05:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NgRz8-0004bD-LD for grub-devel@gnu.org; Sat, 13 Feb 2010 19:05:14 -0500 Received: from relay2-d.mail.gandi.net ([217.70.183.194]:37320) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NgRz8-0004b9-FB for grub-devel@gnu.org; Sat, 13 Feb 2010 19:05:14 -0500 Received: from mail.pina.cat (197.Red-80-32-81.staticIP.rima-tde.net [80.32.81.197]) by relay2-d.mail.gandi.net (Postfix) with ESMTPA id 89D7D225187 for ; Sun, 14 Feb 2010 01:05:11 +0100 (CET) Received: from pinux (cpc2-hari6-0-0-cust86.hari.cable.virginmedia.com [82.45.164.87]) by mail.pina.cat (Postfix) with ESMTPA id 00202288F3087 for ; Sun, 14 Feb 2010 01:05:10 +0100 (CET) Received: by pinux (Postfix, from userid 1000) id 1AD2FEF95F; Sun, 14 Feb 2010 00:05:10 +0000 (GMT) Date: Sun, 14 Feb 2010 00:05:10 +0000 From: Carles Pina i Estany To: grub-devel@gnu.org Message-ID: <20100214000510.GA10702@pina.cat> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="3MwIy2ne0vdjdPXF" Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: avoid possible overflow? X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 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: Sun, 14 Feb 2010 00:05:15 -0000 --3MwIy2ne0vdjdPXF Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hello, The common pattern when doing a search by bisection is something like: + current = min + (max - min) / 2; Instead of the first natural idea: - current = (max + min) / 2; To avoid overflows. In gettext/gettext.c it's used in the "incorrect" way. It's not a big problem since would happen only with .mo files with lot of strings, like number that int represents in that architecture divided by 2 (aprox aprox.). See the attached file for a patch if we want to patch. Else I would at least add a comment that we simplified because we consider that will not happen. Thanks, -- Carles Pina i Estany http://pinux.info --3MwIy2ne0vdjdPXF Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="gettext_overflow.patch" === modified file 'ChangeLog' --- ChangeLog 2010-02-13 15:48:22 +0000 +++ ChangeLog 2010-02-14 00:02:48 +0000 @@ -1,3 +1,8 @@ +2010-02-13 Carles Pina i Estany + + * gettext/gettext.c (grub_gettext_translate): Avoids possible + overflow. + 2010-02-13 Vladimir Serbinenko Merge grub_ieee1275_map_physical into grub_map and rename to === modified file 'gettext/gettext.c' --- gettext/gettext.c 2010-01-20 08:12:47 +0000 +++ gettext/gettext.c 2010-02-13 23:56:58 +0000 @@ -192,7 +192,7 @@ grub_gettext_translate (const char *orig grub_free (current_string); found = 1; } - current = (max + min) / 2; + current = min + (max - min) / 2; } ret = found ? grub_gettext_gettranslation_from_position (current) : orig; --3MwIy2ne0vdjdPXF--