Skip to content

Commit 19ebb29

Browse files
michalpasztamobicahugueskamba
authored andcommitted
storage: fix potential memory corruption and check return values
1 parent 17fd795 commit 19ebb29

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

components/storage/blockdevice/COMPONENT_SPIF/SPIFBlockDevice.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,10 @@ int SPIFBlockDevice::_reset_flash_mem()
936936
tr_error("Sending RST failed");
937937
status = -1;
938938
}
939-
_is_mem_ready();
939+
if (false == _is_mem_ready()) {
940+
tr_error("Device not ready, write failed");
941+
status = -1;
942+
}
940943
}
941944
}
942945

features/storage/filesystem/fat/ChaN/ff.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2719,7 +2719,7 @@ void get_fileinfo (
27192719
if (wc == 0) { di = 0; break; } /* Buffer overflow? */
27202720
di += wc;
27212721
#else /* ANSI/OEM output */
2722-
if (di <= FF_SFN_BUF) fno->altname[di++] = (TCHAR)wc; /* Store it without any conversion */
2722+
if (di < FF_SFN_BUF) fno->altname[di++] = (TCHAR)wc; /* Store it without any conversion */
27232723
#endif
27242724
}
27252725
fno->altname[di] = 0; /* Terminate the SFN (null string means SFN is invalid) */

features/storage/filesystem/littlefs/littlefs/lfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2481,7 +2481,7 @@ int lfs_deorphan(lfs_t *lfs) {
24812481
}
24822482

24832483
lfs_dir_t pdir = {.d.size = 0x80000000};
2484-
lfs_dir_t cwd = {.d.tail[0] = 0, .d.tail[1] = 1};
2484+
lfs_dir_t cwd = {.d.tail = {0,1}};
24852485

24862486
// iterate over all directory directory entries
24872487
while (!lfs_pairisnull(cwd.d.tail)) {

0 commit comments

Comments
 (0)