| OLD | NEW |
| 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_cert_types.h" | 5 #include "net/cert/x509_cert_types.h" |
| 6 | 6 |
| 7 #include <cstdlib> | 7 #include <cstdlib> |
| 8 #include <cstring> | 8 #include <cstring> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/strings/string_piece.h" | 11 #include "base/strings/string_piece.h" |
| 12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 13 #include "net/base/parse_number.h" | 13 #include "net/base/parse_number.h" |
| 14 #include "net/cert/x509_certificate.h" | 14 #include "net/cert/x509_certificate.h" |
| 15 | 15 |
| 16 namespace net { | 16 namespace net { |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 // Helper for ParseCertificateDate. |*field| must contain at least | 20 // Helper for ParseCertificateDate. |*field| must contain at least |
| 21 // |field_len| characters. |*field| will be advanced by |field_len| on exit. | 21 // |field_len| characters. |*field| will be advanced by |field_len| on exit. |
| 22 // |*ok| is set to false if there is an error in parsing the number, but left | 22 // |*ok| is set to false if there is an error in parsing the number, but left |
| 23 // untouched otherwise. Returns the parsed integer. | 23 // untouched otherwise. Returns the parsed integer. |
| 24 int ParseIntAndAdvance(const char** field, size_t field_len, bool* ok) { | 24 int ParseIntAndAdvance(const char** field, size_t field_len, bool* ok) { |
| 25 int result = 0; | 25 int result = 0; |
| 26 *ok &= | 26 *ok &= ParseNonNegativeInteger(base::StringPiece(*field, field_len), &result); |
| 27 ParseNonNegativeDecimalInt(base::StringPiece(*field, field_len), &result); | |
| 28 *field += field_len; | 27 *field += field_len; |
| 29 return result; | 28 return result; |
| 30 } | 29 } |
| 31 | 30 |
| 32 } | 31 } |
| 33 | 32 |
| 34 CertPrincipal::CertPrincipal() { | 33 CertPrincipal::CertPrincipal() { |
| 35 } | 34 } |
| 36 | 35 |
| 37 CertPrincipal::CertPrincipal(const std::string& name) : common_name(name) {} | 36 CertPrincipal::CertPrincipal(const std::string& name) : common_name(name) {} |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 valid &= exploded.HasValidValues(); | 73 valid &= exploded.HasValidValues(); |
| 75 | 74 |
| 76 if (!valid) | 75 if (!valid) |
| 77 return false; | 76 return false; |
| 78 | 77 |
| 79 *time = base::Time::FromUTCExploded(exploded); | 78 *time = base::Time::FromUTCExploded(exploded); |
| 80 return true; | 79 return true; |
| 81 } | 80 } |
| 82 | 81 |
| 83 } // namespace net | 82 } // namespace net |
| OLD | NEW |