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

Unified Diff: net/cert/crl_set_storage.cc

Issue 761903003: Update from https://crrev.com/306655 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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/cert/cert_policy_enforcer_unittest.cc ('k') | net/cert/ct_log_response_parser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/cert/crl_set_storage.cc
diff --git a/net/cert/crl_set_storage.cc b/net/cert/crl_set_storage.cc
index 1b11d78e02495da6abe24ba773939fa09b1118cf..2da4f929be96067f7af3c22b50de4bfdd7d9c68a 100644
--- a/net/cert/crl_set_storage.cc
+++ b/net/cert/crl_set_storage.cc
@@ -8,6 +8,7 @@
#include "base/debug/trace_event.h"
#include "base/format_macros.h"
#include "base/json/json_reader.h"
+#include "base/numerics/safe_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/values.h"
#include "crypto/sha2.h"
@@ -517,10 +518,12 @@ std::string CRLSetStorage::Serialize(const CRLSet* crl_set) {
}
std::string ret;
- char* out = WriteInto(&ret, len + 1 /* to include final NUL */);
+ uint8_t* out = reinterpret_cast<uint8_t*>(
+ WriteInto(&ret, len + 1 /* to include final NUL */));
size_t off = 0;
- out[off++] = header.size();
- out[off++] = header.size() >> 8;
+ CHECK(base::IsValueInRangeForNumericType<uint16>(header.size()));
+ out[off++] = static_cast<uint8_t>(header.size());
+ out[off++] = static_cast<uint8_t>(header.size() >> 8);
memcpy(out + off, header.data(), header.size());
off += header.size();
@@ -534,7 +537,8 @@ std::string CRLSetStorage::Serialize(const CRLSet* crl_set) {
for (std::vector<std::string>::const_iterator j = i->second.begin();
j != i->second.end(); ++j) {
- out[off++] = j->size();
+ CHECK(base::IsValueInRangeForNumericType<uint8_t>(j->size()));
+ out[off++] = static_cast<uint8_t>(j->size());
memcpy(out + off, j->data(), j->size());
off += j->size();
}
« no previous file with comments | « net/cert/cert_policy_enforcer_unittest.cc ('k') | net/cert/ct_log_response_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698