Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent bin_file() -> is_utf8_well_formed() buffer overrun (#271)
When supplied with a file of random data >256 bytes, read() would return a full buffer of data[256] to bin_file(). That function loops through the buffer, but calls is_utf8_well_formed() with the full length of the buffer. When looping on the last byte of the buffer, is_uft8_well_formed() reads past the end. This commit fixes bin_file() to only inspect the remaining bytes in the buffer. Found and tested with CheriBSD on an Arm Morello platform running with strong memory safety
- Loading branch information