diff options
author | Matt Kangas <matt.kangas@mongodb.com> | 2014-06-17 23:34:32 -0400 |
---|---|---|
committer | Ramon Fernandez <ramon@mongodb.com> | 2015-02-09 13:56:40 -0500 |
commit | 0de9b597c0dba9401fbcd2dfbe8f51bb55ce3241 (patch) | |
tree | de22bd0061a0beaa49344dc7cb103142b14dd538 | |
parent | 78d52ff64110f5590e60554c4ba58a68772e61df (diff) | |
download | mongo-0de9b597c0dba9401fbcd2dfbe8f51bb55ce3241.tar.gz |
SERVER-14190 fix possible non-null terminated string in mongorestore
(cherry picked from commit 4f3cf19d951ce143c541c01cd4ec87d06f40556d)
-rw-r--r-- | src/mongo/tools/restore.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/mongo/tools/restore.cpp b/src/mongo/tools/restore.cpp index e49cb61dcfc..27cd6a2c785 100644 --- a/src/mongo/tools/restore.cpp +++ b/src/mongo/tools/restore.cpp @@ -767,11 +767,13 @@ private: long long fileSize = boost::filesystem::file_size(filePath); ifstream file(filePath.c_str(), ios_base::in); - boost::scoped_array<char> buf(new char[fileSize]); + boost::scoped_array<char> buf(new char[fileSize + 1]); file.read(buf.get(), fileSize); + buf[fileSize] = '\0'; + int objSize; BSONObj obj; - obj = fromjson (buf.get(), &objSize); + obj = fromjson(buf.get(), &objSize); return obj; } |