]> git.ipfire.org Git - thirdparty/grub.git/commit
normal/charset: Fix underflow and overflow in loop init
authorLidong Chen <lidong.chen@oracle.com>
Wed, 18 Jun 2025 19:24:23 +0000 (19:24 +0000)
committerDaniel Kiper <daniel.kiper@oracle.com>
Thu, 26 Jun 2025 15:19:25 +0000 (17:19 +0200)
commit8c2d4e64ffe86f46d7f9cd8d4837d5e012a661c6
tree25bdab01f9c600df70754b2c9c9f1e565ff17b4e
parentba8eadde6be1a411e838d0914277bdc3f317cda1
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>
grub-core/normal/charset.c