forked from len0rd/rockbox
diskcache: Size the buffers for MAX_LOG_SECTOR_SIZE
Because if we get a logical sector size > min sector size we'll trigger buffer overflows. Change-Id: Ibd24f91a0f8601fbd8c5a5dfeef4ebe5c081f664
This commit is contained in:
parent
e29ddfb6be
commit
f58fad943e
2 changed files with 13 additions and 10 deletions
|
@ -173,7 +173,7 @@ bool disk_init(IF_MD_NONVOID(int drive))
|
|||
disk_writer_unlock();
|
||||
|
||||
#ifdef MAX_LOG_SECTOR_SIZE
|
||||
if (info->sector_size > MAX_LOG_SECTOR_SIZE) {
|
||||
if (info->sector_size > MAX_LOG_SECTOR_SIZE || info->sector_size > DC_CACHE_BUFSIZE) {
|
||||
panicf("Unsupported logical sector size: %d",
|
||||
info->sector_size);
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ bool disk_init(IF_MD_NONVOID(int drive))
|
|||
#endif
|
||||
#endif /* CONFIG_STORAGE & STORAGE_ATA */
|
||||
|
||||
memset(sector, 0, LOG_SECTOR_SIZE(drive));
|
||||
memset(sector, 0, DC_CACHE_BUFSIZE);
|
||||
storage_read_sectors(IF_MD(drive,) 0, 1, sector);
|
||||
|
||||
bool init = false;
|
||||
|
|
|
@ -35,14 +35,6 @@
|
|||
|
||||
#define MAX_COMPNAME 260
|
||||
|
||||
/* still experimental? */
|
||||
/* increasing this will increase the total memory used by the cache; the
|
||||
cache, as noted in disk_cache.h, has other minimum requirements that may
|
||||
prevent reducing its number of entries in order to compensate */
|
||||
#ifndef SECTOR_SIZE
|
||||
#define SECTOR_SIZE 512
|
||||
#endif
|
||||
|
||||
/* limits for number of open descriptors - if you increase these values, make
|
||||
certain that the disk cache has enough available buffers */
|
||||
|
||||
|
@ -108,7 +100,18 @@
|
|||
#define DC_MAP_NUM_ENTRIES 256
|
||||
#endif /* MEMORYSIZE */
|
||||
|
||||
/* increasing this will increase the total memory used by the cache; the
|
||||
cache, as noted in disk_cache.h, has other minimum requirements that may
|
||||
prevent reducing its number of entries in order to compensate */
|
||||
#ifndef SECTOR_SIZE
|
||||
#define SECTOR_SIZE 512
|
||||
#endif
|
||||
|
||||
/* this _could_ be larger than a sector if that would ever be useful */
|
||||
#ifdef MAX_LOG_SECTOR_SIZE
|
||||
#define DC_CACHE_BUFSIZE MAX_LOG_SECTOR_SIZE
|
||||
#else
|
||||
#define DC_CACHE_BUFSIZE SECTOR_SIZE
|
||||
#endif
|
||||
|
||||
#endif /* FS_DEFINES_H */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue