Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F137950293
D26524.id77375.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D26524.id77375.diff
View Options
Index: sbin/fsck_msdosfs/dir.c
===================================================================
--- sbin/fsck_msdosfs/dir.c
+++ sbin/fsck_msdosfs/dir.c
@@ -388,7 +388,8 @@
checksize(struct fat_descriptor *fat, u_char *p, struct dosDirEntry *dir)
{
int ret = FSOK;
- size_t physicalSize;
+ size_t chainsize;
+ u_int64_t physicalSize;
struct bootblock *boot;
boot = fat_get_boot(fat);
@@ -401,9 +402,9 @@
} else {
if (!fat_is_valid_cl(fat, dir->head))
return FSERROR;
- ret = checkchain(fat, dir->head, &physicalSize);
+ ret = checkchain(fat, dir->head, &chainsize);
/*
- * Upon return, physicalSize would hold the chain length
+ * Upon return, chainsize would hold the chain length
* that checkchain() was able to validate, but if the user
* refused the proposed repair, it would be unsafe to
* proceed with directory entry fix, so bail out in that
@@ -412,7 +413,13 @@
if (ret == FSERROR) {
return (FSERROR);
}
- physicalSize *= boot->ClusterSize;
+ /*
+ * The maximum file size on FAT32 is 4GiB - 1, which
+ * will occupy a cluster chain of exactly 4GiB in
+ * size. On 32-bit platforms, since size_t is 32-bit,
+ * it would wrap back to 0.
+ */
+ physicalSize = (u_int64_t)chainsize * boot->ClusterSize;
}
if (physicalSize < dir->size) {
pwarn("size of %s is %u, should at most be %zu\n",
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 28, 2:50 PM (3 h, 10 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
26286346
Default Alt Text
D26524.id77375.diff (1 KB)
Attached To
Mode
D26524: Fix an integer overflow on 32-bit platforms.
Attached
Detach File
Event Timeline
Log In to Comment