From 2565acbc288b8657bb3dfecef4800e783ae9d28a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20M=C3=BAdry?= Date: Fri, 20 May 2022 14:51:11 +0200 Subject: [PATCH] fatfs: Fix possible integer overflow in esp_vfs_fat_info() --- components/fatfs/vfs/vfs_fat.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/fatfs/vfs/vfs_fat.c b/components/fatfs/vfs/vfs_fat.c index 680bab9879..8dc304595e 100644 --- a/components/fatfs/vfs/vfs_fat.c +++ b/components/fatfs/vfs/vfs_fat.c @@ -222,8 +222,8 @@ esp_err_t esp_vfs_fat_info(const char* base_path, errno = fresult_to_errno(res); return ESP_FAIL; } - uint64_t total_sectors = (fs->n_fatent - 2) * fs->csize; - uint64_t free_sectors = free_clusters * fs->csize; + uint64_t total_sectors = ((uint64_t)(fs->n_fatent - 2)) * fs->csize; + uint64_t free_sectors = ((uint64_t)free_clusters) * fs->csize; // Assuming the total size is < 4GiB, should be true for SPI Flash if (out_total_bytes != NULL) {