[parted-devel] [PATCH 2/5] resize: Make sure 32bit build cannot overflow frag_count
Brian C. Lane
bcl at redhat.com
Mon Sep 14 19:10:01 BST 2026
Add a couple of PED_ASSERT checks to fat_op_context_new that make sure
the frag_count value can be allocated. Does not effect 64bit
architectures.
---
libparted/fs/r/fat/context.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/libparted/fs/r/fat/context.c b/libparted/fs/r/fat/context.c
index cd6211e0..c9a415e0 100644
--- a/libparted/fs/r/fat/context.c
+++ b/libparted/fs/r/fat/context.c
@@ -96,6 +96,8 @@ fat_op_context_new (PedFileSystem* new_fs, PedFileSystem* old_fs)
if (!ctx->buffer_map)
goto error_free_ctx;
+ PED_ASSERT (old_fs_info->frag_count > 0);
+ PED_ASSERT ((size_t) old_fs_info->frag_count < SIZE_MAX / sizeof (FatFragment));
ctx->remap = (FatFragment*) ped_malloc (sizeof (FatFragment)
* old_fs_info->frag_count);
if (!ctx->remap)
--
2.55.0
More information about the parted-devel
mailing list