acolomb/libcintelhex — pull request #1 by acolomb (2014-03-20 11:48:35+00:00)
Title: Fix parsing of unterminated data in memory

The actual parsing work is currently done in the ihex_rs_from_string() function. However, it assumes that the string data is NUL-terminated, which is most certainly not the case for files mapped with ihex_rs_from_file(). The current checks for *data = 0 should work on most platforms since the process address space memory is usually initialized to zero. However, it still generates an invalid read operation past the allocated data, as a check with e.g. valgrind quickly shows.
The proposed solution is to pre-calculate and respect the data length during parsing.