Index: net/disk_cache/simple/simple_test_util.cc |
diff --git a/net/disk_cache/simple/simple_test_util.cc b/net/disk_cache/simple/simple_test_util.cc |
index 9463b63eab4ce6a9e61986adb1fbacec6e036d4d..0251f3ad9142a8023b9fe8465706cccd408a6c6e 100644 |
--- a/net/disk_cache/simple/simple_test_util.cc |
+++ b/net/disk_cache/simple/simple_test_util.cc |
@@ -37,8 +37,10 @@ bool RemoveKeySHA256FromEntry(const std::string& key, |
File entry_file(entry_file_path, flags); |
if (!entry_file.IsValid()) |
return false; |
- int file_length = entry_file.GetLength(); |
+ int64_t file_length = entry_file.GetLength(); |
SimpleFileEOF eof_record; |
+ if (file_length < static_cast<int64_t>(sizeof(eof_record))) |
+ return false; |
if (entry_file.Read(file_length - sizeof(eof_record), |
reinterpret_cast<char*>(&eof_record), |
sizeof(eof_record)) != sizeof(eof_record)) { |
@@ -73,8 +75,10 @@ bool CorruptKeySHA256FromEntry(const std::string& key, |
File entry_file(entry_file_path, flags); |
if (!entry_file.IsValid()) |
return false; |
- int file_length = entry_file.GetLength(); |
+ int64_t file_length = entry_file.GetLength(); |
SimpleFileEOF eof_record; |
+ if (file_length < static_cast<int64_t>(sizeof(eof_record))) |
+ return false; |
if (entry_file.Read(file_length - sizeof(eof_record), |
reinterpret_cast<char*>(&eof_record), |
sizeof(eof_record)) != sizeof(eof_record)) { |
@@ -105,8 +109,10 @@ bool CorruptStream0LengthFromEntry(const std::string& key, |
File entry_file(entry_file_path, flags); |
if (!entry_file.IsValid()) |
return false; |
- int file_length = entry_file.GetLength(); |
+ int64_t file_length = entry_file.GetLength(); |
SimpleFileEOF eof_record; |
+ if (file_length < static_cast<int64_t>(sizeof(eof_record))) |
+ return false; |
if (entry_file.Read(file_length - sizeof(eof_record), |
reinterpret_cast<char*>(&eof_record), |
sizeof(eof_record)) != sizeof(eof_record)) { |