]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
fs/xfs: Fix grub_xfs_iterate_dir() return value in case of failure
authorEgor Ignatov <egori@altlinux.org>
Thu, 23 Jan 2025 17:44:14 +0000 (20:44 +0300)
committerDaniel Kiper <daniel.kiper@oracle.com>
Wed, 26 Feb 2025 19:44:36 +0000 (20:44 +0100)
Commit ef7850c757 (fs/xfs: Fix issues found while fuzzing the XFS
filesystem) introduced multiple boundary checks in grub_xfs_iterate_dir()
but handled the error incorrectly returning error code instead of 0.
Fix it. Also change the error message so that it doesn't match the
message in grub_xfs_read_inode().

Fixes: ef7850c757 (fs/xfs: Fix issues found while fuzzing the XFS filesystem)
Signed-off-by: Egor Ignatov <egori@altlinux.org>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/fs/xfs.c

index 33e16bde5f30dcb8a9cc8e21eb2683faaa07e590..cc0becbbeb581f51d9f1d444005c4f9bf47773c3 100644 (file)
@@ -885,7 +885,11 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
            grub_uint8_t c;
 
            if ((inopos + (smallino ? 4 : 8)) > (grub_uint8_t *) dir + grub_xfs_fshelp_size (dir->data))
-             return grub_error (GRUB_ERR_BAD_FS, "not a correct XFS inode");
+             {
+               grub_error (GRUB_ERR_BAD_FS, "invalid XFS inode");
+               return 0;
+             }
+
 
            /* inopos might be unaligned.  */
            if (smallino)
@@ -1004,7 +1008,10 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
 
                filename = (char *)(direntry + 1);
                if (filename + direntry->len + 1 > (char *) end)
-                 return grub_error (GRUB_ERR_BAD_FS, "invalid XFS directory entry");
+                 {
+                   grub_error (GRUB_ERR_BAD_FS, "invalid XFS directory entry");
+                   return 0;
+                 }
 
                /* The byte after the filename is for the filetype, padding, or
                   tag, which is not used by GRUB.  So it can be overwritten. */