|
From: Roger B. <an...@xp...> - 2018-03-07 23:08:46
|
The attached patch fixes a bug in the TOSONLY code in usb_storage.c. It does not affect FreeMiNT, but it does affect the STORAGE.PRG that is used in support of USB sticks on plain TOS (and EmuTOS), and the code is in the FreeMiNT sources, so I am submitting the patch here. Problem description: During STORAGE.PRG startup, if the current max_sect_siz in the AHDI structure is not the same as the maximum logical sector size obtained from XHDI, the program installs a new AHDI structure and a new set of cache buffers. It then copies the data from the old buffers to the new ones. However, it only copies the first 512 bytes of each buffer; the rest of the buffer was zeroed after being malloc'ed and remains that way. As a result, if max_sect_siz is not the same as the XHDI size, and max_sect_siz is greater than 512, the in-memory copy of sectors will be corrupt after STORAGE.PRG has run. If the cached sectors are from directories, then files or folders will temporarily disappear; if those sectors are subsequently written to, the bad data will be flushed to disk, causing filesystem corruption. Fix: The fix merely sets the copy length correctly. Roger Burrows |