git: f37dc94abcae - stable/14 - loader: dosfs fails to access directory data with large cluster number

From: Toomas Soome <tsoome_at_FreeBSD.org>
Date: Thu, 10 Oct 2024 12:54:01 UTC
The branch stable/14 has been updated by tsoome:

URL: https://cgit.FreeBSD.org/src/commit/?id=f37dc94abcaedc31421f5433b23522fe2ee1506b

commit f37dc94abcaedc31421f5433b23522fe2ee1506b
Author:     Toomas Soome <tsoome@FreeBSD.org>
AuthorDate: 2024-10-03 11:54:11 +0000
Commit:     Toomas Soome <tsoome@FreeBSD.org>
CommitDate: 2024-10-10 12:52:50 +0000

    loader: dosfs fails to access directory data with large cluster number
    
    fsize is using 2 bytes for cluster number, but with fat32 we
    actually do have 4 bytes and with large disks the high bytes will be in use.
    
    illumos issue: https://www.illumos.org/issues/16821
    
    Sponsored by:   MNX Cloud, Inc.
    
    (cherry-picked from commit 79a0d14fa05c75038caa52099289effb85732f88)
---
 stand/libsa/dosfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/stand/libsa/dosfs.c b/stand/libsa/dosfs.c
index 7fbbf65989ae..2ee95bf2c601 100644
--- a/stand/libsa/dosfs.c
+++ b/stand/libsa/dosfs.c
@@ -815,7 +815,7 @@ fsize(DOS_FS *fs, DOS_DE *de)
 	int n;
 
 	if (!(size = cv4(de->size)) && de->attr & FA_DIR) {
-		if (!(c = cv2(de->clus))) {
+		if (!(c = stclus(fs->fatsz, de))) {
 			size = fs->dirents * sizeof(DOS_DE);
 		} else {
 			if ((n = fatcnt(fs, c)) == -1)