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/spdy/fuzzing/hpack_fuzz_util.h" | 5 #include "net/spdy/core/fuzzing/hpack_fuzz_util.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/rand_util.h" | 10 #include "base/rand_util.h" |
11 #include "base/sys_byteorder.h" | 11 #include "base/sys_byteorder.h" |
12 #include "net/spdy/hpack/hpack_constants.h" | 12 #include "net/spdy/core/hpack/hpack_constants.h" |
13 | 13 |
14 namespace net { | 14 namespace net { |
15 | 15 |
16 namespace { | 16 namespace { |
17 | 17 |
18 // Sampled exponential distribution parameters: | 18 // Sampled exponential distribution parameters: |
19 // Number of headers in each header set. | 19 // Number of headers in each header set. |
20 const size_t kHeaderCountMean = 7; | 20 const size_t kHeaderCountMean = 7; |
21 const size_t kHeaderCountMax = 50; | 21 const size_t kHeaderCountMax = 50; |
22 // Selected index within list of headers. | 22 // Selected index within list of headers. |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 uint64_t bits_to_flip = flip_per_thousand * (1 + buffer_bit_length / 1024); | 181 uint64_t bits_to_flip = flip_per_thousand * (1 + buffer_bit_length / 1024); |
182 | 182 |
183 // Iteratively identify & flip offsets in the buffer bit-sequence. | 183 // Iteratively identify & flip offsets in the buffer bit-sequence. |
184 for (uint64_t i = 0; i != bits_to_flip; ++i) { | 184 for (uint64_t i = 0; i != bits_to_flip; ++i) { |
185 uint64_t bit_offset = base::RandUint64() % buffer_bit_length; | 185 uint64_t bit_offset = base::RandUint64() % buffer_bit_length; |
186 buffer[bit_offset / 8u] ^= (1 << (bit_offset % 8u)); | 186 buffer[bit_offset / 8u] ^= (1 << (bit_offset % 8u)); |
187 } | 187 } |
188 } | 188 } |
189 | 189 |
190 } // namespace net | 190 } // namespace net |
OLD | NEW |