Fix an overflow in blkcnt_t gpt_last_lba

If CONFIG_FS_LARGEFILE is not defined, the calculation overflows for larger
disks, since blkcnt_t is 32 bits.

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
This commit is contained in:
Jukka Laitinen 2022-01-19 13:44:33 +02:00 committed by Alin Jerpelea
parent a6147109b1
commit ae31cbde09

View File

@ -173,8 +173,8 @@ static const struct gpt_guid_s g_null_guid;
static inline blkcnt_t gpt_last_lba(FAR struct partition_state_s *state)
{
return (state->nblocks * state->blocksize + GPT_BLOCK_SIZE - 1) /
GPT_BLOCK_SIZE - 1;
return (((uint64_t)state->nblocks) * state->blocksize + GPT_BLOCK_SIZE - 1)
/ GPT_BLOCK_SIZE - 1;
}
/****************************************************************************