Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1188)

Unified Diff: net/disk_cache/simple/simple_disk_format.cc

Issue 14204002: Remove some uninitialized reads from simple cache metadata serializer. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: more memset goodness Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/disk_cache/simple/simple_disk_format.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/disk_cache/simple/simple_disk_format.cc
diff --git a/net/disk_cache/simple/simple_disk_format.cc b/net/disk_cache/simple/simple_disk_format.cc
index 0a254dd30a38ce311bef5ef9d9c6dc9f4bf4b4c1..9dd44ede343c88047f29e36f959f11c33fcfd517 100644
--- a/net/disk_cache/simple/simple_disk_format.cc
+++ b/net/disk_cache/simple/simple_disk_format.cc
@@ -27,16 +27,30 @@ std::string GetEntryHashForKey(const std::string& key) {
namespace SimpleIndexFile {
-EntryMetadata::EntryMetadata() :
- last_used_time(0),
- entry_size(0) {
+Footer::Footer() {
+ // Make hashing repeatable: leave no padding bytes untouched.
+ memset(this, 0, sizeof(*this));
+}
+
+Header::Header() {
+ // Make hashing repeatable: leave no padding bytes untouched.
+ memset(this, 0, sizeof(*this));
+}
+
+EntryMetadata::EntryMetadata() {
+ // Make hashing repeatable: leave no padding bytes untouched.
+ memset(this, 0, sizeof(*this));
}
EntryMetadata::EntryMetadata(const std::string& hash_key_p,
base::Time last_used_time_p,
- uint64 entry_size_p) :
- last_used_time(last_used_time_p.ToInternalValue()),
- entry_size(entry_size_p) {
+ uint64 entry_size_p) {
+ // Make hashing repeatable: leave no padding bytes untouched.
+ memset(this, 0, sizeof(*this));
+
+ // Proceed with field initializations.
+ entry_size = entry_size_p;
+ last_used_time = last_used_time_p.ToInternalValue();
DCHECK_EQ(kEntryHashKeySize, implicit_cast<int>(hash_key_p.size()));
hash_key_p.copy(hash_key, kEntryHashKeySize);
}
« no previous file with comments | « net/disk_cache/simple/simple_disk_format.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698