Merge pull request #11269 from michalpasztamobica/coverity_fixes

storage: fix potential memory corruption and check return values
pull/11316/head
Martin Kojtal 2019-08-23 15:49:14 +02:00 committed by GitHub
commit b005bf2133
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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)) {