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

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

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

commit c66f901b8e4101435a1671fb943031198361beb1
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:55:03 +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 06215b1ab0fd..6f7b207ff404 100644
--- a/stand/libsa/dosfs.c
+++ b/stand/libsa/dosfs.c
@@ -816,7 +816,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)