diff options
author | Logan Chien <loganchien@google.com> | 2017-10-16 06:04:34 (GMT) |
---|---|---|
committer | Logan Chien <loganchien@google.com> | 2017-10-16 06:04:34 (GMT) |
commit | 7c80007b55fd42cdd56b06cb4330fb8ceb468e09 (patch) | |
tree | 352bfffc96a13fe85faeaf2c463ca80161e7f3bd /src/deps_log.cc | |
parent | 887eccf1fdd91d50c4761bba79b5cf329a280ffb (diff) | |
download | Ninja-7c80007b55fd42cdd56b06cb4330fb8ceb468e09.zip Ninja-7c80007b55fd42cdd56b06cb4330fb8ceb468e09.tar.gz Ninja-7c80007b55fd42cdd56b06cb4330fb8ceb468e09.tar.bz2 |
Fix potential buffer overrun
This commit rearranges record size comparison and fread() to make sure
fread() only reads the data that can fit into the buffer.
Diffstat (limited to 'src/deps_log.cc')
-rw-r--r-- | src/deps_log.cc | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/deps_log.cc b/src/deps_log.cc index 89c6023..8734dd7 100644 --- a/src/deps_log.cc +++ b/src/deps_log.cc @@ -209,7 +209,7 @@ bool DepsLog::Load(const string& path, State* state, string* err) { bool is_deps = (size >> 31) != 0; size = size & 0x7FFFFFFF; - if (fread(buf, size, 1, f) < 1 || size > kMaxRecordSize) { + if (size > kMaxRecordSize || fread(buf, size, 1, f) < 1) { read_failed = true; break; } |