repart: use INC_SAFE for partition min size accumulation
Use overflow-safe INC_SAFE() instead of raw addition when
accumulating partition minimum size components.
CID#1548041
Follow-up for 170c982345
This commit is contained in:
+3
-3
@@ -1133,16 +1133,16 @@ static uint64_t partition_min_size(const Context *context, const Partition *p) {
|
||||
uint64_t d = 0;
|
||||
|
||||
if (p->encrypt != ENCRYPT_OFF)
|
||||
d += round_up_size(LUKS2_METADATA_KEEP_FREE, context->grain_size);
|
||||
assert_se(INC_SAFE(&d, round_up_size(LUKS2_METADATA_KEEP_FREE, context->grain_size)));
|
||||
|
||||
if (p->copy_blocks_size != UINT64_MAX)
|
||||
d += round_up_size(p->copy_blocks_size, context->grain_size);
|
||||
assert_se(INC_SAFE(&d, round_up_size(p->copy_blocks_size, context->grain_size)));
|
||||
else if (p->format || p->encrypt != ENCRYPT_OFF) {
|
||||
uint64_t f;
|
||||
|
||||
/* If we shall synthesize a file system, take minimal fs size into account (assumed to be 4K if not known) */
|
||||
f = partition_fstype_min_size(context, p);
|
||||
d += f == UINT64_MAX ? context->grain_size : round_up_size(f, context->grain_size);
|
||||
assert_se(INC_SAFE(&d, f == UINT64_MAX ? context->grain_size : round_up_size(f, context->grain_size)));
|
||||
}
|
||||
|
||||
if (d > sz)
|
||||
|
||||
Reference in New Issue
Block a user