This is an automated email from the ASF dual-hosted git repository. bcall pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push: new ea338f6 all or nothing for readIntoBuffer ea338f6 is described below commit ea338f66974192c7ab906a1a4e020a696afb8cd7 Author: Alan Wang <xf6w...@gmail.com> AuthorDate: Mon Mar 5 16:07:47 2018 -0800 all or nothing for readIntoBuffer --- lib/ts/MatcherUtils.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/ts/MatcherUtils.cc b/lib/ts/MatcherUtils.cc index 218d9a5..f0421e5 100644 --- a/lib/ts/MatcherUtils.cc +++ b/lib/ts/MatcherUtils.cc @@ -41,10 +41,10 @@ // int* read_size_ptr) // // Attempts to open and read arg file_path into a buffer allocated -// off the heap (via malloc() ) Returns a pointer to the buffer +// off the heap (via ats_malloc() ) Returns a pointer to the buffer // is successful and nullptr otherwise. // -// CALLEE is responsibled for deallocating the buffer via free() +// CALLEE is responsibled for deallocating the buffer via ats_free() // char * readIntoBuffer(const char *file_path, const char *module_name, int *read_size_ptr) @@ -90,10 +90,12 @@ readIntoBuffer(const char *file_path, const char *module_name, int *read_size_pt ats_free(file_buf); file_buf = nullptr; } else if (read_size < file_info.st_size) { - // We don't want to signal this error on WIN32 because the sizes - // won't match if the file contains any CR/LF sequence. + // Didn't get the whole file, drop everything. We don't want to return + // something partially read because, ie. with configs, the behaviour + // is undefined. Error("%s Only able to read %d bytes out %d for %s file", module_name, read_size, (int)file_info.st_size, file_path); - file_buf[read_size] = '\0'; + ats_free(file_buf); + file_buf = nullptr; } if (file_buf && read_size_ptr) { -- To stop receiving notification emails like this one, please contact bc...@apache.org.