OLD | NEW |
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/quic/crypto/quic_server_info.h" | 5 #include "net/quic/crypto/quic_server_info.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/pickle.h" | 9 #include "base/pickle.h" |
10 | 10 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 | 60 |
61 // No data was read from the disk cache. | 61 // No data was read from the disk cache. |
62 if (data.empty()) { | 62 if (data.empty()) { |
63 return false; | 63 return false; |
64 } | 64 } |
65 | 65 |
66 Pickle p(data.data(), data.size()); | 66 Pickle p(data.data(), data.size()); |
67 PickleIterator iter(p); | 67 PickleIterator iter(p); |
68 | 68 |
69 int version = -1; | 69 int version = -1; |
70 if (!iter.ReadInt(&version)) { | 70 if (!p.ReadInt(&iter, &version)) { |
71 DVLOG(1) << "Missing version"; | 71 DVLOG(1) << "Missing version"; |
72 return false; | 72 return false; |
73 } | 73 } |
74 | 74 |
75 if (version != kQuicCryptoConfigVersion) { | 75 if (version != kQuicCryptoConfigVersion) { |
76 DVLOG(1) << "Unsupported version"; | 76 DVLOG(1) << "Unsupported version"; |
77 return false; | 77 return false; |
78 } | 78 } |
79 | 79 |
80 if (!iter.ReadString(&state->server_config)) { | 80 if (!p.ReadString(&iter, &state->server_config)) { |
81 DVLOG(1) << "Malformed server_config"; | 81 DVLOG(1) << "Malformed server_config"; |
82 return false; | 82 return false; |
83 } | 83 } |
84 if (!iter.ReadString(&state->source_address_token)) { | 84 if (!p.ReadString(&iter, &state->source_address_token)) { |
85 DVLOG(1) << "Malformed source_address_token"; | 85 DVLOG(1) << "Malformed source_address_token"; |
86 return false; | 86 return false; |
87 } | 87 } |
88 if (!iter.ReadString(&state->server_config_sig)) { | 88 if (!p.ReadString(&iter, &state->server_config_sig)) { |
89 DVLOG(1) << "Malformed server_config_sig"; | 89 DVLOG(1) << "Malformed server_config_sig"; |
90 return false; | 90 return false; |
91 } | 91 } |
92 | 92 |
93 // Read certs. | 93 // Read certs. |
94 uint32 num_certs; | 94 uint32 num_certs; |
95 if (!iter.ReadUInt32(&num_certs)) { | 95 if (!p.ReadUInt32(&iter, &num_certs)) { |
96 DVLOG(1) << "Malformed num_certs"; | 96 DVLOG(1) << "Malformed num_certs"; |
97 return false; | 97 return false; |
98 } | 98 } |
99 | 99 |
100 for (uint32 i = 0; i < num_certs; i++) { | 100 for (uint32 i = 0; i < num_certs; i++) { |
101 string cert; | 101 string cert; |
102 if (!iter.ReadString(&cert)) { | 102 if (!p.ReadString(&iter, &cert)) { |
103 DVLOG(1) << "Malformed cert"; | 103 DVLOG(1) << "Malformed cert"; |
104 return false; | 104 return false; |
105 } | 105 } |
106 state->certs.push_back(cert); | 106 state->certs.push_back(cert); |
107 } | 107 } |
108 | 108 |
109 return true; | 109 return true; |
110 } | 110 } |
111 | 111 |
112 string QuicServerInfo::Serialize() { | 112 string QuicServerInfo::Serialize() { |
(...skipping 19 matching lines...) Expand all Loading... |
132 return string(); | 132 return string(); |
133 } | 133 } |
134 } | 134 } |
135 | 135 |
136 return string(reinterpret_cast<const char *>(p.data()), p.size()); | 136 return string(reinterpret_cast<const char *>(p.data()), p.size()); |
137 } | 137 } |
138 | 138 |
139 QuicServerInfoFactory::~QuicServerInfoFactory() {} | 139 QuicServerInfoFactory::~QuicServerInfoFactory() {} |
140 | 140 |
141 } // namespace net | 141 } // namespace net |
OLD | NEW |