From: Daniel Axtens Date: Mon, 18 Jan 2021 03:51:11 +0000 (+1100) Subject: fs/jfs: Do not move to leaf level if name length is negative X-Git-Tag: grub-2.06-rc1~67 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ffd5a46f68710e2781899d0be4d701429a5a817d;p=thirdparty%2Fgrub.git fs/jfs: Do not move to leaf level if name length is negative Fuzzing JFS revealed crashes where a negative number would be passed to le_to_cpu16_copy(). There it would be cast to a large positive number and the copy would read and write off the end of the respective buffers. Catch this at the top as well as the bottom of the loop. Signed-off-by: Daniel Axtens Reviewed-by: Daniel Kiper --- diff --git a/grub-core/fs/jfs.c b/grub-core/fs/jfs.c index d5a6d6527..e5bbda61c 100644 --- a/grub-core/fs/jfs.c +++ b/grub-core/fs/jfs.c @@ -567,7 +567,7 @@ grub_jfs_getent (struct grub_jfs_diropen *diro) /* Move down to the leaf level. */ nextent = leaf->next; - if (leaf->next != 255) + if (leaf->next != 255 && len > 0) do { next_leaf = &diro->next_leaf[nextent];