Problem
Path inputs validate size using stat(), then later read using unrestricted readFile().
If file grows or is replaced between these operations, it can exceed maxFileSize, consume excessive memory, and return stale size metadata.
Proposed fix
- Read from one opened file handle
- Read at most
maxBytes + 1
- Throw
InputTooLargeError when exceeded
- Close handle in
finally
- Report actual bytes read
Acceptance criteria
- Oversized path input rejected
- File growth/replacement cannot bypass limit
result.size matches actual input
- Add generated temporary-file regression tests
Problem
Path inputs validate size using
stat(), then later read using unrestrictedreadFile().If file grows or is replaced between these operations, it can exceed
maxFileSize, consume excessive memory, and return stale size metadata.Proposed fix
maxBytes + 1InputTooLargeErrorwhen exceededfinallyAcceptance criteria
result.sizematches actual input