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

Side by Side Diff: net/quic/crypto/crypto_framer.cc

Issue 12310041: experiment with -Wimplicit-fallthrough Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: rebase Created 6 years, 12 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 | Annotate | Revision Log
« no previous file with comments | « net/http/http_pipelined_host_impl.cc ('k') | net/quic/quic_config.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 (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/quic/crypto/crypto_framer.h" 5 #include "net/quic/crypto/crypto_framer.h"
6 6
7 #include "net/quic/crypto/crypto_handshake.h" 7 #include "net/quic/crypto/crypto_handshake.h"
8 #include "net/quic/quic_data_reader.h" 8 #include "net/quic/quic_data_reader.h"
9 #include "net/quic/quic_data_writer.h" 9 #include "net/quic/quic_data_writer.h"
10 10
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 201
202 switch (state_) { 202 switch (state_) {
203 case STATE_READING_TAG: 203 case STATE_READING_TAG:
204 if (reader.BytesRemaining() < kQuicTagSize) { 204 if (reader.BytesRemaining() < kQuicTagSize) {
205 break; 205 break;
206 } 206 }
207 QuicTag message_tag; 207 QuicTag message_tag;
208 reader.ReadUInt32(&message_tag); 208 reader.ReadUInt32(&message_tag);
209 message_.set_tag(message_tag); 209 message_.set_tag(message_tag);
210 state_ = STATE_READING_NUM_ENTRIES; 210 state_ = STATE_READING_NUM_ENTRIES;
211 FALLTHROUGH_INTENDED;
211 case STATE_READING_NUM_ENTRIES: 212 case STATE_READING_NUM_ENTRIES:
212 if (reader.BytesRemaining() < kNumEntriesSize + sizeof(uint16)) { 213 if (reader.BytesRemaining() < kNumEntriesSize + sizeof(uint16)) {
213 break; 214 break;
214 } 215 }
215 reader.ReadUInt16(&num_entries_); 216 reader.ReadUInt16(&num_entries_);
216 if (num_entries_ > kMaxEntries) { 217 if (num_entries_ > kMaxEntries) {
217 return QUIC_CRYPTO_TOO_MANY_ENTRIES; 218 return QUIC_CRYPTO_TOO_MANY_ENTRIES;
218 } 219 }
219 uint16 padding; 220 uint16 padding;
220 reader.ReadUInt16(&padding); 221 reader.ReadUInt16(&padding);
221 222
222 tags_and_lengths_.reserve(num_entries_); 223 tags_and_lengths_.reserve(num_entries_);
223 state_ = STATE_READING_TAGS_AND_LENGTHS; 224 state_ = STATE_READING_TAGS_AND_LENGTHS;
224 values_len_ = 0; 225 values_len_ = 0;
226 FALLTHROUGH_INTENDED;
225 case STATE_READING_TAGS_AND_LENGTHS: { 227 case STATE_READING_TAGS_AND_LENGTHS: {
226 if (reader.BytesRemaining() < 228 if (reader.BytesRemaining() <
227 num_entries_ * (kQuicTagSize + kCryptoEndOffsetSize)) { 229 num_entries_ * (kQuicTagSize + kCryptoEndOffsetSize)) {
228 break; 230 break;
229 } 231 }
230 232
231 uint32 last_end_offset = 0; 233 uint32 last_end_offset = 0;
232 for (unsigned i = 0; i < num_entries_; ++i) { 234 for (unsigned i = 0; i < num_entries_; ++i) {
233 QuicTag tag; 235 QuicTag tag;
234 reader.ReadUInt32(&tag); 236 reader.ReadUInt32(&tag);
235 if (i > 0 && tag <= tags_and_lengths_[i-1].first) { 237 if (i > 0 && tag <= tags_and_lengths_[i-1].first) {
236 if (tag == tags_and_lengths_[i-1].first) { 238 if (tag == tags_and_lengths_[i-1].first) {
237 return QUIC_CRYPTO_DUPLICATE_TAG; 239 return QUIC_CRYPTO_DUPLICATE_TAG;
238 } 240 }
239 return QUIC_CRYPTO_TAGS_OUT_OF_ORDER; 241 return QUIC_CRYPTO_TAGS_OUT_OF_ORDER;
240 } 242 }
241 243
242 uint32 end_offset; 244 uint32 end_offset;
243 reader.ReadUInt32(&end_offset); 245 reader.ReadUInt32(&end_offset);
244 246
245 if (end_offset < last_end_offset) { 247 if (end_offset < last_end_offset) {
246 return QUIC_CRYPTO_TAGS_OUT_OF_ORDER; 248 return QUIC_CRYPTO_TAGS_OUT_OF_ORDER;
247 } 249 }
248 tags_and_lengths_.push_back( 250 tags_and_lengths_.push_back(
249 make_pair(tag, static_cast<size_t>(end_offset - last_end_offset))); 251 make_pair(tag, static_cast<size_t>(end_offset - last_end_offset)));
250 last_end_offset = end_offset; 252 last_end_offset = end_offset;
251 } 253 }
252 values_len_ = last_end_offset; 254 values_len_ = last_end_offset;
253 state_ = STATE_READING_VALUES; 255 state_ = STATE_READING_VALUES;
256 FALLTHROUGH_INTENDED;
254 } 257 }
255 case STATE_READING_VALUES: 258 case STATE_READING_VALUES:
256 if (reader.BytesRemaining() < values_len_) { 259 if (reader.BytesRemaining() < values_len_) {
257 break; 260 break;
258 } 261 }
259 for (vector<pair<QuicTag, size_t> >::const_iterator 262 for (vector<pair<QuicTag, size_t> >::const_iterator
260 it = tags_and_lengths_.begin(); it != tags_and_lengths_.end(); 263 it = tags_and_lengths_.begin(); it != tags_and_lengths_.end();
261 it++) { 264 it++) {
262 StringPiece value; 265 StringPiece value;
263 reader.ReadStringPiece(&value, it->second); 266 reader.ReadStringPiece(&value, it->second);
(...skipping 19 matching lines...) Expand all
283 } 286 }
284 *end_offset += pad_length; 287 *end_offset += pad_length;
285 if (!writer->WriteUInt32(*end_offset)) { 288 if (!writer->WriteUInt32(*end_offset)) {
286 DCHECK(false) << "Failed to write end offset."; 289 DCHECK(false) << "Failed to write end offset.";
287 return false; 290 return false;
288 } 291 }
289 return true; 292 return true;
290 } 293 }
291 294
292 } // namespace net 295 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_pipelined_host_impl.cc ('k') | net/quic/quic_config.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698