martin-helmich/libcintelhex — pull request #10 by acolomb (2014-03-20 12:01:37+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.

This branch depends on the "cleanup" branch, for which Pull Request #9 was opened. I'm not sure if GitHub will correctly handle this dependency. If this poses a problem, please ask me to rebase onto master.