This is an automated email from the ASF dual-hosted git repository.
jerpelea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new ae31cbd Fix an overflow in blkcnt_t gpt_last_lba
ae31cbd is described below
commit ae31cbde090e815b4e97889428fd7b14b8ec43e3
Author: Jukka Laitinen <[email protected]>
AuthorDate: Wed Jan 19 13:44:33 2022 +0200
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 <[email protected]>
---
fs/partition/fs_gpt.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/partition/fs_gpt.c b/fs/partition/fs_gpt.c
index df639cc..90c9ee8 100644
--- a/fs/partition/fs_gpt.c
+++ b/fs/partition/fs_gpt.c
@@ -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;
}
/****************************************************************************