storage: fix potential memory corruption and check return values

pull/11269/head
Michal Paszta 2019-08-21 09:25:54 +03:00
parent e4e6c645fa
commit 5a9183c549
3 changed files with 6 additions and 3 deletions

View File

@ -936,7 +936,10 @@ int SPIFBlockDevice::_reset_flash_mem()
tr_error("Sending RST failed");
status = -1;
}
_is_mem_ready();
if (false == _is_mem_ready()) {
tr_error("Device not ready, write failed");
status = -1;
}
}
}

View File

@ -2719,7 +2719,7 @@ void get_fileinfo (
if (wc == 0) { di = 0; break; } /* Buffer overflow? */
di += wc;
#else /* ANSI/OEM output */
if (di <= FF_SFN_BUF) fno->altname[di++] = (TCHAR)wc; /* Store it without any conversion */
if (di < FF_SFN_BUF) fno->altname[di++] = (TCHAR)wc; /* Store it without any conversion */
#endif
}
fno->altname[di] = 0; /* Terminate the SFN (null string means SFN is invalid) */

View File

@ -2481,7 +2481,7 @@ int lfs_deorphan(lfs_t *lfs) {
}
lfs_dir_t pdir = {.d.size = 0x80000000};
lfs_dir_t cwd = {.d.tail[0] = 0, .d.tail[1] = 1};
lfs_dir_t cwd = {.d.tail = {0,1}};
// iterate over all directory directory entries
while (!lfs_pairisnull(cwd.d.tail)) {