mirror of
https://git.savannah.gnu.org/git/grub.git
synced 2026-10-24 08:09:22 +00:00
normal/charset: Fix underflow and overflow in loop init
In bidi_line_wrap(), "kk - 1" in the for loop init, "i = kk - 1", underflows when "kk" (unsigned int) is 0. Assigning the result of "kk - 1" to signed int "i" may cause overflow. To address both issues, cast "kk" to a signed type before subtraction to ensure safe arithmetic and assignment. Fixed: CID 473874 Signed-off-by: Lidong Chen <lidong.chen@oracle.com> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com> Reviewed-by: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
This commit is contained in:
1 parent
ba8eadde6b
commit
8c2d4e64ff
1 file changed
+1
-1
@@ -738,7 +738,7 @@ bidi_line_wrap (struct grub_unicode_glyph *visual_out,
|
|||||||
{
|
{
|
||||||
int right_join = 0;
|
int right_join = 0;
|
||||||
signed i;
|
signed i;
|
||||||
for (i = kk - 1; i >= 0 && (unsigned) i + 1 > line_start;
|
for (i = (signed) kk - 1; i >= 0 && (unsigned) i + 1 > line_start;
|
||||||
i--)
|
i--)
|
||||||
{
|
{
|
||||||
enum grub_join_type join_type = get_join_type (visual[i].base);
|
enum grub_join_type join_type = get_join_type (visual[i].base);
|
||||||
|
|||||||
Reference in new issue
Block a user