Skip to content

Commit 2e7efde

Browse files
bugfix/sdio_streaming Fixed sdio read len check
Fixed error checking if sdio read len exceeds buffer size when host is not in SDIO Streaming Mode. Prevents stack and heap corruption when SDIO slave is in Streaming Mode but Host is in Packet mode (read too much data, overwriting memory).
1 parent 71f942b commit 2e7efde

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

host/drivers/transport/sdio/sdio_drv.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,14 +203,16 @@ static int sdio_get_len_from_slave(uint32_t *rx_size, bool is_lock_needed)
203203
/* Handle a case of roll over */
204204
temp = ESP_RX_BYTE_MAX - sdio_rx_byte_count;
205205
len = temp + len;
206+
}
206207

207208
#if H_SDIO_HOST_RX_MODE != H_SDIO_HOST_STREAMING_MODE
208-
if (len > ESP_RX_BUFFER_SIZE) {
209-
ESP_LOGI(TAG, "%s: Len from slave[%ld] exceeds max [%d]",
210-
__func__, len, ESP_RX_BUFFER_SIZE);
211-
}
212-
#endif
209+
if (len > ESP_RX_BUFFER_SIZE) {
210+
ESP_LOGE(TAG, "%s: Len from slave[%ld] exceeds max [%d]",
211+
__func__, len, ESP_RX_BUFFER_SIZE);
212+
return ESP_FAIL;
213213
}
214+
#endif
215+
214216
*rx_size = len;
215217

216218
return 0;

0 commit comments

Comments
 (0)