commit | 2a8b1f57895e6cc20d6a1abd859472239a749d8c | [log] [tgz] |
---|---|---|
author | Dmitry-Me <wipedout@yandex.ru> | Thu Apr 30 14:58:57 2015 +0300 |
committer | Dmitry-Me <wipedout@yandex.ru> | Thu Apr 30 14:58:57 2015 +0300 |
tree | 7bf1761f3ad0dbfc5bae1bec842516c9b833e72c | |
parent | 882e89e60188703e57b001c495e07ca6e9b217c3 [diff] [blame] |
Ensure file contents fit into size_t range
diff --git a/tinyxml2.cpp b/tinyxml2.cpp index 50bea56..03ce1b9 100755 --- a/tinyxml2.cpp +++ b/tinyxml2.cpp
@@ -1846,6 +1846,12 @@ return _errorID; } + if ( filelength >= (size_t)-1 ) { + // Cannot handle files which won't fit in buffer together with null terminator + SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 ); + return _errorID; + } + const size_t size = filelength; if ( size == 0 ) { SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 );