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

Side by Side Diff: net/base/x509_certificate_win.cc

Issue 8418034: Make string_util::WriteInto() DCHECK() that the supplied |length_with_null| > 1, meaning that the... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/base/x509_certificate.h" 5 #include "net/base/x509_certificate.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/pickle.h" 9 #include "base/pickle.h"
10 #include "base/sha1.h" 10 #include "base/sha1.h"
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 515
516 void X509Certificate::Initialize() { 516 void X509Certificate::Initialize() {
517 std::wstring subject_info; 517 std::wstring subject_info;
518 std::wstring issuer_info; 518 std::wstring issuer_info;
519 DWORD name_size; 519 DWORD name_size;
520 DCHECK(cert_handle_); 520 DCHECK(cert_handle_);
521 name_size = CertNameToStr(cert_handle_->dwCertEncodingType, 521 name_size = CertNameToStr(cert_handle_->dwCertEncodingType,
522 &cert_handle_->pCertInfo->Subject, 522 &cert_handle_->pCertInfo->Subject,
523 CERT_X500_NAME_STR | CERT_NAME_STR_CRLF_FLAG, 523 CERT_X500_NAME_STR | CERT_NAME_STR_CRLF_FLAG,
524 NULL, 0); 524 NULL, 0);
525 name_size = CertNameToStr(cert_handle_->dwCertEncodingType, 525 if (name_size > 1) {
526 &cert_handle_->pCertInfo->Subject, 526 CertNameToStr(cert_handle_->dwCertEncodingType,
527 CERT_X500_NAME_STR | CERT_NAME_STR_CRLF_FLAG, 527 &cert_handle_->pCertInfo->Subject,
528 WriteInto(&subject_info, name_size), name_size); 528 CERT_X500_NAME_STR | CERT_NAME_STR_CRLF_FLAG,
529 WriteInto(&subject_info, name_size), name_size);
530 }
529 name_size = CertNameToStr(cert_handle_->dwCertEncodingType, 531 name_size = CertNameToStr(cert_handle_->dwCertEncodingType,
530 &cert_handle_->pCertInfo->Issuer, 532 &cert_handle_->pCertInfo->Issuer,
531 CERT_X500_NAME_STR | CERT_NAME_STR_CRLF_FLAG, 533 CERT_X500_NAME_STR | CERT_NAME_STR_CRLF_FLAG,
532 NULL, 0); 534 NULL, 0);
533 name_size = CertNameToStr(cert_handle_->dwCertEncodingType, 535 if (name_size > 1) {
534 &cert_handle_->pCertInfo->Issuer, 536 CertNameToStr(cert_handle_->dwCertEncodingType,
535 CERT_X500_NAME_STR | CERT_NAME_STR_CRLF_FLAG, 537 &cert_handle_->pCertInfo->Issuer,
536 WriteInto(&issuer_info, name_size), name_size); 538 CERT_X500_NAME_STR | CERT_NAME_STR_CRLF_FLAG,
539 WriteInto(&issuer_info, name_size), name_size);
540 }
537 ParsePrincipal(WideToUTF8(subject_info), &subject_); 541 ParsePrincipal(WideToUTF8(subject_info), &subject_);
538 ParsePrincipal(WideToUTF8(issuer_info), &issuer_); 542 ParsePrincipal(WideToUTF8(issuer_info), &issuer_);
539 543
540 valid_start_ = Time::FromFileTime(cert_handle_->pCertInfo->NotBefore); 544 valid_start_ = Time::FromFileTime(cert_handle_->pCertInfo->NotBefore);
541 valid_expiry_ = Time::FromFileTime(cert_handle_->pCertInfo->NotAfter); 545 valid_expiry_ = Time::FromFileTime(cert_handle_->pCertInfo->NotAfter);
542 546
543 fingerprint_ = CalculateFingerprint(cert_handle_); 547 fingerprint_ = CalculateFingerprint(cert_handle_);
544 548
545 const CRYPT_INTEGER_BLOB* serial = &cert_handle_->pCertInfo->SerialNumber; 549 const CRYPT_INTEGER_BLOB* serial = &cert_handle_->pCertInfo->SerialNumber;
546 scoped_array<uint8> serial_bytes(new uint8[serial->cbData]); 550 scoped_array<uint8> serial_bytes(new uint8[serial->cbData]);
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
1052 if (!CertSerializeCertificateStoreElement(cert_handle, 0, &buffer[0], 1056 if (!CertSerializeCertificateStoreElement(cert_handle, 0, &buffer[0],
1053 &length)) { 1057 &length)) {
1054 return false; 1058 return false;
1055 } 1059 }
1056 1060
1057 return pickle->WriteData(reinterpret_cast<const char*>(&buffer[0]), 1061 return pickle->WriteData(reinterpret_cast<const char*>(&buffer[0]),
1058 length); 1062 length);
1059 } 1063 }
1060 1064
1061 } // namespace net 1065 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698