From: B Horn Date: Sun, 12 May 2024 01:03:33 +0000 (+0100) Subject: fs/ufs: Fix a heap OOB write X-Git-Tag: archive/raspbian/2.12-9+rpi1^2~70 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=094e68ad5ce85b351ecb4fe0ae7e06601ec61eda;p=grub2.git fs/ufs: Fix a heap OOB write grub_strcpy() was used to copy a symlink name from the filesystem image to a heap allocated buffer. This led to a OOB write to adjacent heap allocations. Fix by using grub_strlcpy(). Fixes: CVE-2024-45781 Reported-by: B Horn Signed-off-by: B Horn Reviewed-by: Daniel Kiper Gbp-Pq: Topic cve-2025-jan Gbp-Pq: Name fs-ufs-Fix-a-heap-OOB-write.patch --- diff --git a/grub-core/fs/ufs.c b/grub-core/fs/ufs.c index a354c92..0123510 100644 --- a/grub-core/fs/ufs.c +++ b/grub-core/fs/ufs.c @@ -463,7 +463,7 @@ grub_ufs_lookup_symlink (struct grub_ufs_data *data, int ino) /* Check against zero is paylindromic, no need to swap. */ if (data->inode.nblocks == 0 && INODE_SIZE (data) <= sizeof (data->inode.symlink)) - grub_strcpy (symlink, (char *) data->inode.symlink); + grub_strlcpy (symlink, (char *) data->inode.symlink, sz); else { if (grub_ufs_read_file (data, 0, 0, 0, sz, symlink) < 0)