[rtems commit] fat: Fix for invalid cluster sizes
Sebastian Huber
sebh at rtems.org
Fri May 20 06:15:37 UTC 2016
Module: rtems
Branch: 4.10
Commit: 6adad1e70ad24f1c59b06ed91c8c609b26d946d5
Changeset: http://git.rtems.org/rtems/commit/?id=6adad1e70ad24f1c59b06ed91c8c609b26d946d5
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Wed May 18 09:17:09 2016 +0200
fat: Fix for invalid cluster sizes
A cluster size > 32KiB resulted in an infinite loop in
fat_init_volume_info() due to an integer overflow.
Update #2717.
---
cpukit/libfs/src/dosfs/fat.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/cpukit/libfs/src/dosfs/fat.c b/cpukit/libfs/src/dosfs/fat.c
index ad1dd2a..01faf65 100644
--- a/cpukit/libfs/src/dosfs/fat.c
+++ b/cpukit/libfs/src/dosfs/fat.c
@@ -430,12 +430,14 @@ fat_init_volume_info(rtems_filesystem_mount_table_entry_t *mt_entry)
/*
* "bytes per cluster" value greater than 32K is invalid
*/
- if ((vol->bpc = vol->bps << vol->spc_log2) > MS_BYTES_PER_CLUSTER_LIMIT)
+ if (vol->bps > (MS_BYTES_PER_CLUSTER_LIMIT >> vol->spc_log2))
{
rtems_disk_release(vol->dd);
rtems_set_errno_and_return_minus_one(EINVAL);
}
+ vol->bpc = vol->bps << vol->spc_log2;
+
for (vol->bpc_log2 = 0, i = vol->bpc; (i & 1) == 0;
i >>= 1, vol->bpc_log2++);
More information about the vc
mailing list