]> git.ipfire.org Git - thirdparty/grub.git/commit
commands/test: Stack overflow due to unlimited recursion depth
authorLidong Chen <lidong.chen@oracle.com>
Mon, 16 Dec 2024 20:22:41 +0000 (20:22 +0000)
committerDaniel Kiper <daniel.kiper@oracle.com>
Thu, 13 Feb 2025 14:45:56 +0000 (15:45 +0100)
commitc68b7d23628a19da67ebe2e06f84165ee04961af
tree454fe245ac27222013bbef17446c9bb4e9c7fef0
parentdad8f502974ed9ad0a70ae6820d17b4b142558fc
commands/test: Stack overflow due to unlimited recursion depth

The test_parse() evaluates test expression recursively. Due to lack of
recursion depth check a specially crafted expression may cause a stack
overflow. The recursion is only triggered by the parentheses usage and
it can be unlimited. However, sensible expressions are unlikely to
contain more than a few parentheses. So, this patch limits the recursion
depth to 100, which should be sufficient.

Reported-by: Nils Langius <nils@langius.de>
Signed-off-by: Lidong Chen <lidong.chen@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/commands/test.c