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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/cert/crl_set_storage.h" 5 #include "net/cert/crl_set_storage.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
11 #include "base/numerics/safe_conversions.h"
11 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
12 #include "base/values.h" 13 #include "base/values.h"
13 #include "crypto/sha2.h" 14 #include "crypto/sha2.h"
14 #include "third_party/zlib/zlib.h" 15 #include "third_party/zlib/zlib.h"
15 16
16 namespace net { 17 namespace net {
17 18
18 // Decompress zlib decompressed |in| into |out|. |out_len| is the number of 19 // Decompress zlib decompressed |in| into |out|. |out_len| is the number of
19 // bytes at |out| and must be exactly equal to the size of the decompressed 20 // bytes at |out| and must be exactly equal to the size of the decompressed
20 // data. 21 // data.
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 for (CRLSet::CRLList::const_iterator i = crl_set->crls_.begin(); 511 for (CRLSet::CRLList::const_iterator i = crl_set->crls_.begin();
511 i != crl_set->crls_.end(); ++i) { 512 i != crl_set->crls_.end(); ++i) {
512 len += i->first.size() + 4 /* num serials */; 513 len += i->first.size() + 4 /* num serials */;
513 for (std::vector<std::string>::const_iterator j = i->second.begin(); 514 for (std::vector<std::string>::const_iterator j = i->second.begin();
514 j != i->second.end(); ++j) { 515 j != i->second.end(); ++j) {
515 len += 1 /* serial length */ + j->size(); 516 len += 1 /* serial length */ + j->size();
516 } 517 }
517 } 518 }
518 519
519 std::string ret; 520 std::string ret;
520 char* out = WriteInto(&ret, len + 1 /* to include final NUL */); 521 uint8_t* out = reinterpret_cast<uint8_t*>(
522 WriteInto(&ret, len + 1 /* to include final NUL */));
521 size_t off = 0; 523 size_t off = 0;
522 out[off++] = header.size(); 524 CHECK(base::IsValueInRangeForNumericType<uint16>(header.size()));
523 out[off++] = header.size() >> 8; 525 out[off++] = static_cast<uint8_t>(header.size());
526 out[off++] = static_cast<uint8_t>(header.size() >> 8);
524 memcpy(out + off, header.data(), header.size()); 527 memcpy(out + off, header.data(), header.size());
525 off += header.size(); 528 off += header.size();
526 529
527 for (CRLSet::CRLList::const_iterator i = crl_set->crls_.begin(); 530 for (CRLSet::CRLList::const_iterator i = crl_set->crls_.begin();
528 i != crl_set->crls_.end(); ++i) { 531 i != crl_set->crls_.end(); ++i) {
529 memcpy(out + off, i->first.data(), i->first.size()); 532 memcpy(out + off, i->first.data(), i->first.size());
530 off += i->first.size(); 533 off += i->first.size();
531 const uint32 num_serials = i->second.size(); 534 const uint32 num_serials = i->second.size();
532 memcpy(out + off, &num_serials, sizeof(num_serials)); 535 memcpy(out + off, &num_serials, sizeof(num_serials));
533 off += sizeof(num_serials); 536 off += sizeof(num_serials);
534 537
535 for (std::vector<std::string>::const_iterator j = i->second.begin(); 538 for (std::vector<std::string>::const_iterator j = i->second.begin();
536 j != i->second.end(); ++j) { 539 j != i->second.end(); ++j) {
537 out[off++] = j->size(); 540 CHECK(base::IsValueInRangeForNumericType<uint8_t>(j->size()));
541 out[off++] = static_cast<uint8_t>(j->size());
538 memcpy(out + off, j->data(), j->size()); 542 memcpy(out + off, j->data(), j->size());
539 off += j->size(); 543 off += j->size();
540 } 544 }
541 } 545 }
542 546
543 CHECK_EQ(off, len); 547 CHECK_EQ(off, len);
544 return ret; 548 return ret;
545 } 549 }
546 550
547 } // namespace net 551 } // namespace net
OLDNEW
« 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