bdk: sdmmc: check for out bounds access
This commit is contained in:
@@ -27,10 +27,13 @@
|
|||||||
#include <memory_map.h>
|
#include <memory_map.h>
|
||||||
#include <gfx_utils.h>
|
#include <gfx_utils.h>
|
||||||
|
|
||||||
//#define SDMMC_DEBUG_PRINT_SD_REGS
|
|
||||||
//#define DPRINTF(...) gfx_printf(__VA_ARGS__)
|
//#define DPRINTF(...) gfx_printf(__VA_ARGS__)
|
||||||
#define DPRINTF(...)
|
#define DPRINTF(...)
|
||||||
|
|
||||||
|
#ifdef BDK_SDMMC_EXTRA_PRINT
|
||||||
|
#define ERROR_EXTRA_PRINTING
|
||||||
|
#endif
|
||||||
|
|
||||||
u32 sd_power_cycle_time_start;
|
u32 sd_power_cycle_time_start;
|
||||||
|
|
||||||
static inline u32 unstuff_bits(const u32 *resp, u32 start, u32 size)
|
static inline u32 unstuff_bits(const u32 *resp, u32 start, u32 size)
|
||||||
@@ -256,6 +259,15 @@ static int _sdmmc_storage_readwrite(sdmmc_storage_t *storage, u32 sector, u32 nu
|
|||||||
if (!storage->initialized)
|
if (!storage->initialized)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
// Check if out of bounds.
|
||||||
|
if (((u64)sector + num_sectors) > storage->sec_cnt)
|
||||||
|
{
|
||||||
|
#ifdef ERROR_EXTRA_PRINTING
|
||||||
|
EPRINTFARGS("SDMMC%d: Out of bounds!", storage->sdmmc->id + 1);
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
while (sct_total)
|
while (sct_total)
|
||||||
{
|
{
|
||||||
u32 blkcnt = 0;
|
u32 blkcnt = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user