1
0
mirror of https://github.com/mist-devel/mist-firmware.git synced 2026-05-01 22:27:03 +00:00

More safety for SD-reads and writes, watch out for file length

...if the core ignores the size.
This commit is contained in:
Gyorgy Szombathelyi
2019-01-08 22:54:39 +01:00
parent 3611799fe9
commit 61624c6014

View File

@@ -1108,8 +1108,10 @@ void user_io_poll() {
#if 1
if(sd_image[drive_index].file.size) {
IDXSeek(&sd_image[drive_index], lba);
IDXWrite(&sd_image[drive_index], wr_buf);
if(((sd_image[drive_index].file.size-1) >> 9) >= lba) {
IDXSeek(&sd_image[drive_index], lba);
IDXWrite(&sd_image[drive_index], wr_buf);
}
} else
MMC_Write(lba, wr_buf);
#else
@@ -1134,8 +1136,10 @@ void user_io_poll() {
if(buffer_lba != lba) {
DISKLED_ON;
if(sd_image[drive_index].file.size) {
IDXSeek(&sd_image[drive_index], lba);
IDXRead(&sd_image[drive_index], buffer);
if(((sd_image[drive_index].file.size-1) >> 9) >= lba) {
IDXSeek(&sd_image[drive_index], lba);
IDXRead(&sd_image[drive_index], buffer);
}
} else {
// sector read
// read sector from sd card if it is not already present in