]> git.ipfire.org Git - thirdparty/grub.git/commit
osdep/unix/getroot: Fix potential underflow
authorLidong Chen <lidong.chen@oracle.com>
Wed, 29 Jan 2025 06:48:38 +0000 (06:48 +0000)
committerDaniel Kiper <daniel.kiper@oracle.com>
Thu, 13 Feb 2025 14:45:58 +0000 (15:45 +0100)
commit66733f7c7dae889861ea3ef3ec0710811486019e
treed84fc9f40a47d9f8794e61fd55992ada9a22b04a
parentd13b6e8ebd10b4eb16698a002aa40258cf6e6f0e
osdep/unix/getroot: Fix potential underflow

The entry_len is initialized in grub_find_root_devices_from_mountinfo()
to 0 before the while loop iterates through /proc/self/mountinfo. If the
file is empty or contains only invalid entries entry_len remains
0 causing entry_len - 1 in the subsequent for loop initialization
to underflow. To prevent this add a check to ensure entry_len > 0 before
entering the for loop.

Fixes: CID 473877
Signed-off-by: Lidong Chen <lidong.chen@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
Reviewed-by: Ross Philipson <ross.philipson@oracle.com>
grub-core/osdep/linux/getroot.c