Commit c4c1464
committed
fix(security): VFS write overflow, file close robustness, catalog safety
VFS_WriteFile:
- Add overflow check before rounding endPos up to 4KB boundary. If
endPos > 0xFFFFF000, adding 4095 wraps to a small value, causing
undersized allocation and subsequent buffer overflow on memcpy.
VFS_CloseFile:
- Remove restriction that only 'created' overlay entries can persist
data (any overlay entry with file data should be saved)
- NULL-out fileData/fileDataSize before freeing to prevent dangling
pointer if NewPtr fails
- Only update modTime if GetDateTime returns non-zero (avoid setting
file timestamp to Mac epoch on failure)
HFS_CatalogLookup:
- Use strlen-based length comparison before character loop instead of
relying on null terminator probe at entries[i].name[len]. While the
original was safe (len <= 31, name[32]), the new approach is clearer
and avoids assumptions about null termination of catalog names.1 parent 03ea572 commit c4c1464
2 files changed
+13
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
241 | 241 | | |
242 | 242 | | |
243 | 243 | | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
244 | 248 | | |
245 | 249 | | |
246 | 250 | | |
| |||
252 | 256 | | |
253 | 257 | | |
254 | 258 | | |
255 | | - | |
| 259 | + | |
256 | 260 | | |
257 | 261 | | |
258 | 262 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
896 | 896 | | |
897 | 897 | | |
898 | 898 | | |
899 | | - | |
| 899 | + | |
900 | 900 | | |
901 | 901 | | |
902 | 902 | | |
| 903 | + | |
| 904 | + | |
903 | 905 | | |
904 | 906 | | |
905 | 907 | | |
| |||
911 | 913 | | |
912 | 914 | | |
913 | 915 | | |
914 | | - | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
915 | 919 | | |
916 | 920 | | |
917 | 921 | | |
| |||
955 | 959 | | |
956 | 960 | | |
957 | 961 | | |
958 | | - | |
| 962 | + | |
| 963 | + | |
959 | 964 | | |
960 | 965 | | |
961 | 966 | | |
| |||
0 commit comments