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
=== 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 <car...@pina.cat> + + * gettext/gettext.c (grub_gettext_translate): Avoids possible + overflow. + 2010-02-13 Vladimir Serbinenko <phco...@gmail.com> 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;
_______________________________________________ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel