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

Unified Diff: net/cert/crl_set_storage.cc

Issue 1158923005: Use the exact-width integer types defined in <stdint.h> rather than (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tweak comments. Exclude mime_sniffer*. Rebase. Created 5 years, 7 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/cert/crl_set.cc ('k') | net/cert/crl_set_unittest.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 a952584d9921a1fdaee95056975f8b15691c42e7..86b24609302e02a0d791e1e18d5053e19e5b029d 100644
--- a/net/cert/crl_set_storage.cc
+++ b/net/cert/crl_set_storage.cc
@@ -19,7 +19,7 @@ namespace net {
// Decompress zlib decompressed |in| into |out|. |out_len| is the number of
// bytes at |out| and must be exactly equal to the size of the decompressed
// data.
-static bool DecompressZlib(uint8* out, int out_len, base::StringPiece in) {
+static bool DecompressZlib(uint8_t* out, int out_len, base::StringPiece in) {
z_stream z;
memset(&z, 0, sizeof(z));
@@ -51,16 +51,16 @@ static bool DecompressZlib(uint8* out, int out_len, base::StringPiece in) {
// byte[32] parent_spki_sha256
// uint32le num_serials
// [num_serials] {
-// uint8 serial_length;
+// uint8_t serial_length;
// byte[serial_length] serial;
// }
//
// header_bytes consists of a JSON dictionary with the following keys:
// Version (int): currently 0
// ContentType (string): "CRLSet" or "CRLSetDelta" (magic value)
-// DeltaFrom (int32): if this is a delta update (see below), then this
+// DeltaFrom (int32_t): if this is a delta update (see below), then this
// contains the sequence number of the base CRLSet.
-// Sequence (int32): the monotonic sequence number of this CRL set.
+// Sequence (int32_t): the monotonic sequence number of this CRL set.
//
// A delta CRLSet is similar to a CRLSet:
//
@@ -91,7 +91,7 @@ static bool DecompressZlib(uint8* out, int out_len, base::StringPiece in) {
// // the serial is the same
// case 1:
// // serial inserted
-// uint8 serial_length
+// uint8_t serial_length
// byte[serial_length] serial
// case 2:
// // serial deleted
@@ -114,8 +114,8 @@ static bool DecompressZlib(uint8* out, int out_len, base::StringPiece in) {
static base::DictionaryValue* ReadHeader(base::StringPiece* data) {
if (data->size() < 2)
return NULL;
- uint16 header_len;
- memcpy(&header_len, data->data(), 2); // assumes little-endian.
+ uint16_t header_len;
+ memcpy(&header_len, data->data(), 2); // Assumes little-endian.
eroman 2015/06/03 22:10:39 your translation is correct fine. however it seems
wtc 2015/06/04 01:03:04 Done. See https://codereview.chromium.org/11704930
data->remove_prefix(2);
if (data->size() < header_len)
@@ -145,22 +145,23 @@ static bool ReadCRL(base::StringPiece* data, std::string* out_parent_spki_hash,
out_parent_spki_hash->assign(data->data(), crypto::kSHA256Length);
data->remove_prefix(crypto::kSHA256Length);
- if (data->size() < sizeof(uint32))
+ if (data->size() < sizeof(uint32_t))
return false;
- uint32 num_serials;
- memcpy(&num_serials, data->data(), sizeof(uint32)); // assumes little endian
+ uint32_t num_serials;
+ // Assumes little endian.
+ memcpy(&num_serials, data->data(), sizeof(uint32_t));
eroman 2015/06/03 22:10:39 for instance here sizeof(num_serials) would be mor
wtc 2015/06/04 01:03:04 ARM, MIPS, and PowerPC can be configured to be big
if (num_serials > 32 * 1024 * 1024) // Sanity check.
return false;
out_serials->reserve(num_serials);
- data->remove_prefix(sizeof(uint32));
+ data->remove_prefix(sizeof(uint32_t));
- for (uint32 i = 0; i < num_serials; ++i) {
- if (data->size() < sizeof(uint8))
+ for (uint32_t i = 0; i < num_serials; ++i) {
+ if (data->size() < sizeof(uint8_t))
return false;
- uint8 serial_length = data->data()[0];
- data->remove_prefix(sizeof(uint8));
+ uint8_t serial_length = data->data()[0];
+ data->remove_prefix(sizeof(uint8_t));
if (data->size() < serial_length)
return false;
@@ -211,14 +212,14 @@ bool CRLSetStorage::CopyBlockedSPKIsFromHeader(
static const unsigned kMaxUncompressedChangesLength = 1024 * 1024;
static bool ReadChanges(base::StringPiece* data,
- std::vector<uint8>* out_changes) {
- uint32 uncompressed_size, compressed_size;
- if (data->size() < 2 * sizeof(uint32))
+ std::vector<uint8_t>* out_changes) {
+ uint32_t uncompressed_size, compressed_size;
+ if (data->size() < 2 * sizeof(uint32_t))
return false;
- // assumes little endian.
- memcpy(&uncompressed_size, data->data(), sizeof(uint32));
+ // Assumes little endian.
+ memcpy(&uncompressed_size, data->data(), sizeof(uint32_t));
data->remove_prefix(4);
- memcpy(&compressed_size, data->data(), sizeof(uint32));
+ memcpy(&compressed_size, data->data(), sizeof(uint32_t));
data->remove_prefix(4);
if (uncompressed_size > kMaxUncompressedChangesLength)
@@ -247,12 +248,12 @@ enum {
static bool ReadDeltaCRL(base::StringPiece* data,
const std::vector<std::string>& old_serials,
std::vector<std::string>* out_serials) {
- std::vector<uint8> changes;
+ std::vector<uint8_t> changes;
if (!ReadChanges(data, &changes))
return false;
size_t i = 0;
- for (std::vector<uint8>::const_iterator k = changes.begin();
+ for (std::vector<uint8_t>::const_iterator k = changes.begin();
k != changes.end(); ++k) {
if (*k == SYMBOL_SAME) {
if (i >= old_serials.size())
@@ -260,11 +261,11 @@ static bool ReadDeltaCRL(base::StringPiece* data,
out_serials->push_back(old_serials[i]);
i++;
} else if (*k == SYMBOL_INSERT) {
- uint8 serial_length;
- if (data->size() < sizeof(uint8))
+ uint8_t serial_length;
+ if (data->size() < sizeof(uint8_t))
return false;
- memcpy(&serial_length, data->data(), sizeof(uint8));
- data->remove_prefix(sizeof(uint8));
+ memcpy(&serial_length, data->data(), sizeof(uint8_t));
+ data->remove_prefix(sizeof(uint8_t));
if (data->size() < serial_length)
return false;
@@ -330,8 +331,8 @@ bool CRLSetStorage::Parse(base::StringPiece data,
return false;
scoped_refptr<CRLSet> crl_set(new CRLSet());
- crl_set->sequence_ = static_cast<uint32>(sequence);
- crl_set->not_after_ = static_cast<uint64>(not_after);
+ crl_set->sequence_ = static_cast<uint32_t>(sequence);
+ crl_set->not_after_ = static_cast<uint64_t>(not_after);
crl_set->crls_.reserve(64); // Value observed experimentally.
for (size_t crl_index = 0; !data.empty(); crl_index++) {
@@ -381,9 +382,8 @@ bool CRLSetStorage::ApplyDelta(const CRLSet* in_crl_set,
int sequence, delta_from;
if (!header_dict->GetInteger("Sequence", &sequence) ||
- !header_dict->GetInteger("DeltaFrom", &delta_from) ||
- delta_from < 0 ||
- static_cast<uint32>(delta_from) != in_crl_set->sequence_) {
+ !header_dict->GetInteger("DeltaFrom", &delta_from) || delta_from < 0 ||
+ static_cast<uint32_t>(delta_from) != in_crl_set->sequence_) {
return false;
}
@@ -396,19 +396,19 @@ bool CRLSetStorage::ApplyDelta(const CRLSet* in_crl_set,
return false;
scoped_refptr<CRLSet> crl_set(new CRLSet);
- crl_set->sequence_ = static_cast<uint32>(sequence);
- crl_set->not_after_ = static_cast<uint64>(not_after);
+ crl_set->sequence_ = static_cast<uint32_t>(sequence);
+ crl_set->not_after_ = static_cast<uint64_t>(not_after);
if (!CopyBlockedSPKIsFromHeader(crl_set.get(), header_dict.get()))
return false;
- std::vector<uint8> crl_changes;
+ std::vector<uint8_t> crl_changes;
if (!ReadChanges(&data, &crl_changes))
return false;
size_t i = 0, j = 0;
- for (std::vector<uint8>::const_iterator k = crl_changes.begin();
+ for (std::vector<uint8_t>::const_iterator k = crl_changes.begin();
k != crl_changes.end(); ++k) {
if (*k == SYMBOL_SAME) {
if (i >= in_crl_set->crls_.size())
@@ -521,7 +521,7 @@ std::string CRLSetStorage::Serialize(const CRLSet* crl_set) {
uint8_t* out = reinterpret_cast<uint8_t*>(
WriteInto(&ret, len + 1 /* to include final NUL */));
size_t off = 0;
- CHECK(base::IsValueInRangeForNumericType<uint16>(header.size()));
+ CHECK(base::IsValueInRangeForNumericType<uint16_t>(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());
@@ -531,7 +531,7 @@ std::string CRLSetStorage::Serialize(const CRLSet* crl_set) {
i != crl_set->crls_.end(); ++i) {
memcpy(out + off, i->first.data(), i->first.size());
off += i->first.size();
- const uint32 num_serials = i->second.size();
+ const uint32_t num_serials = i->second.size();
memcpy(out + off, &num_serials, sizeof(num_serials));
off += sizeof(num_serials);
« no previous file with comments | « net/cert/crl_set.cc ('k') | net/cert/crl_set_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698