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

Side by Side Diff: net/cert/x509_certificate.cc

Issue 2760723002: Check X509Certificate::CreateFromHandle result. (Closed)
Patch Set: 2nd round of updates Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/x509_certificate.h" 5 #include "net/cert/x509_certificate.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 #include <stdlib.h> 8 #include <stdlib.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 kFormatDecodePriority[i]); 438 kFormatDecodePriority[i]);
439 } 439 }
440 440
441 CertificateList results; 441 CertificateList results;
442 // No certificates parsed. 442 // No certificates parsed.
443 if (certificates.empty()) 443 if (certificates.empty())
444 return results; 444 return results;
445 445
446 for (OSCertHandles::iterator it = certificates.begin(); 446 for (OSCertHandles::iterator it = certificates.begin();
447 it != certificates.end(); ++it) { 447 it != certificates.end(); ++it) {
448 results.push_back(CreateFromHandle(*it, OSCertHandles())); 448 scoped_refptr<X509Certificate> cert =
449 CreateFromHandle(*it, OSCertHandles());
450 if (cert)
451 results.push_back(std::move(cert));
449 FreeOSCertHandle(*it); 452 FreeOSCertHandle(*it);
450 } 453 }
451 454
452 return results; 455 return results;
453 } 456 }
454 457
455 void X509Certificate::Persist(base::Pickle* pickle) { 458 void X509Certificate::Persist(base::Pickle* pickle) {
456 DCHECK(cert_handle_); 459 DCHECK(cert_handle_);
457 // This would be an absolutely insane number of intermediates. 460 // This would be an absolutely insane number of intermediates.
458 if (intermediate_ca_certs_.size() > static_cast<size_t>(INT_MAX) - 1) { 461 if (intermediate_ca_certs_.size() > static_cast<size_t>(INT_MAX) - 1) {
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 RemoveFromCache(cert_handle_); 722 RemoveFromCache(cert_handle_);
720 FreeOSCertHandle(cert_handle_); 723 FreeOSCertHandle(cert_handle_);
721 } 724 }
722 for (size_t i = 0; i < intermediate_ca_certs_.size(); ++i) { 725 for (size_t i = 0; i < intermediate_ca_certs_.size(); ++i) {
723 RemoveFromCache(intermediate_ca_certs_[i]); 726 RemoveFromCache(intermediate_ca_certs_[i]);
724 FreeOSCertHandle(intermediate_ca_certs_[i]); 727 FreeOSCertHandle(intermediate_ca_certs_[i]);
725 } 728 }
726 } 729 }
727 730
728 } // namespace net 731 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698