From 483149e41b435ff3734c559222b6a644bbc1e2b1 Mon Sep 17 00:00:00 2001 From: morris Date: Thu, 7 Apr 2022 19:14:37 +0800 Subject: [PATCH] global: fix some potential out-of-bounds issue ...that found by Coverity Scan --- components/driver/rmt.c | 3 ++- components/esp_system/esp_ipc.c | 2 +- components/vfs/vfs.c | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/components/driver/rmt.c b/components/driver/rmt.c index 397845ac8f..c414786508 100644 --- a/components/driver/rmt.c +++ b/components/driver/rmt.c @@ -713,8 +713,9 @@ esp_err_t rmt_config(const rmt_config_t *rmt_param) static void IRAM_ATTR rmt_fill_memory(rmt_channel_t channel, const rmt_item32_t *item, uint16_t item_num, uint16_t mem_offset) { - volatile uint32_t *to = (volatile uint32_t *)&RMTMEM.chan[channel].data32[mem_offset].val; uint32_t *from = (uint32_t *)item; + volatile uint32_t *to = (volatile uint32_t *)&RMTMEM.chan[channel].data32[0].val; + to += mem_offset; while (item_num--) { *to++ = *from++; } diff --git a/components/esp_system/esp_ipc.c b/components/esp_system/esp_ipc.c index 2db3dbf921..d015cafb02 100644 --- a/components/esp_system/esp_ipc.c +++ b/components/esp_system/esp_ipc.c @@ -107,7 +107,7 @@ static void esp_ipc_init(void) __attribute__((constructor)); static void esp_ipc_init(void) { - char task_name[15]; + char task_name[configMAX_TASK_NAME_LEN]; for (int i = 0; i < portNUM_PROCESSORS; ++i) { snprintf(task_name, sizeof(task_name), "ipc%d", i); diff --git a/components/vfs/vfs.c b/components/vfs/vfs.c index a0e42cff78..d8c034bc0e 100644 --- a/components/vfs/vfs.c +++ b/components/vfs/vfs.c @@ -167,7 +167,7 @@ esp_err_t esp_vfs_register_with_id(const esp_vfs_t *vfs, void *ctx, esp_vfs_id_t esp_err_t esp_vfs_unregister_with_id(esp_vfs_id_t vfs_id) { - if (vfs_id < 0 || vfs_id >= MAX_FDS || s_vfs[vfs_id] == NULL) { + if (vfs_id < 0 || vfs_id >= VFS_MAX_COUNT || s_vfs[vfs_id] == NULL) { return ESP_ERR_INVALID_ARG; } vfs_entry_t* vfs = s_vfs[vfs_id];