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

Side by Side Diff: net/spdy/spdy_framer.cc

Issue 989283002: Fix off-by-one in SpdyFramer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« no previous file with comments | « no previous file | no next file » | 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/spdy/spdy_framer.h" 5 #include "net/spdy/spdy_framer.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/third_party/valgrind/memcheck.h" 9 #include "base/third_party/valgrind/memcheck.h"
10 #include "net/spdy/spdy_frame_builder.h" 10 #include "net/spdy/spdy_frame_builder.h"
(...skipping 2950 matching lines...) Expand 10 before | Expand all | Expand 10 after
2961 z_stream* compressor = GetHeaderCompressor(); 2961 z_stream* compressor = GetHeaderCompressor();
2962 // Since we'll be performing lots of flushes when compressing the data, 2962 // Since we'll be performing lots of flushes when compressing the data,
2963 // zlib's lower bounds may be insufficient. 2963 // zlib's lower bounds may be insufficient.
2964 return 2 * deflateBound(compressor, uncompressed_length); 2964 return 2 * deflateBound(compressor, uncompressed_length);
2965 } 2965 }
2966 2966
2967 size_t SpdyFramer::GetNumberRequiredContinuationFrames(size_t size) { 2967 size_t SpdyFramer::GetNumberRequiredContinuationFrames(size_t size) {
2968 DCHECK_GT(protocol_version(), SPDY3); 2968 DCHECK_GT(protocol_version(), SPDY3);
2969 DCHECK_GT(size, kMaxControlFrameSize); 2969 DCHECK_GT(size, kMaxControlFrameSize);
2970 size_t overflow = size - kMaxControlFrameSize; 2970 size_t overflow = size - kMaxControlFrameSize;
2971 return overflow / (kMaxControlFrameSize - GetContinuationMinimumSize()) + 1; 2971 size_t payload_size = kMaxControlFrameSize - GetContinuationMinimumSize();
2972 // This is ceiling(overflow/payload_size) using integer arithmetics.
2973 return (overflow - 1) / payload_size + 1;
Ryan Hamilton 2015/03/09 17:50:08 Looks like this has not yet been fixed in google3'
2972 } 2974 }
2973 2975
2974 void SpdyFramer::WritePayloadWithContinuation(SpdyFrameBuilder* builder, 2976 void SpdyFramer::WritePayloadWithContinuation(SpdyFrameBuilder* builder,
2975 const string& hpack_encoding, 2977 const string& hpack_encoding,
2976 SpdyStreamId stream_id, 2978 SpdyStreamId stream_id,
2977 SpdyFrameType type, 2979 SpdyFrameType type,
2978 int padding_payload_len) { 2980 int padding_payload_len) {
2979 uint8 end_flag = 0; 2981 uint8 end_flag = 0;
2980 uint8 flags = 0; 2982 uint8 flags = 0;
2981 if (type == HEADERS) { 2983 if (type == HEADERS) {
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
3277 #else 3279 #else
3278 WriteHeaderBlockToZ(&frame.name_value_block(), compressor); 3280 WriteHeaderBlockToZ(&frame.name_value_block(), compressor);
3279 #endif // defined(USE_SYSTEM_ZLIB) 3281 #endif // defined(USE_SYSTEM_ZLIB)
3280 3282
3281 int compressed_size = compressed_max_size - compressor->avail_out; 3283 int compressed_size = compressed_max_size - compressor->avail_out;
3282 builder->Seek(compressed_size); 3284 builder->Seek(compressed_size);
3283 builder->RewriteLength(*this); 3285 builder->RewriteLength(*this);
3284 } 3286 }
3285 3287
3286 } // namespace net 3288 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698