git: 79a0d14fa05c - main - loader: dosfs fails to access directory data with large cluster number

From: Toomas Soome <tsoome_at_FreeBSD.org>
Date: Thu, 03 Oct 2024 13:52:34 UTC
The branch main has been updated by tsoome:

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

commit 79a0d14fa05c75038caa52099289effb85732f88
Author:     Toomas Soome <tsoome@FreeBSD.org>
AuthorDate: 2024-10-03 11:54:11 +0000
Commit:     Toomas Soome <tsoome@FreeBSD.org>
CommitDate: 2024-10-03 13:51:59 +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.
    MFC after:      1 week
---
 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)