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

Side by Side Diff: webrtc/test/fuzzers/rtp_header_fuzzer.cc

Issue 2062103002: Add a libfuzzer for RtpHeaderParser. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: update as per code review Created 4 years, 6 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 | « webrtc/test/fuzzers/BUILD.gn ('k') | 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
(Empty)
1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include <bitset>
12
13 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_received.h"
14 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
15 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h"
16
17 namespace webrtc {
18 void FuzzOneInput(const uint8_t* data, size_t size) {
19 if (size <= 1)
20 return;
21
22 // We decide which header extensions to register by reading one byte
23 // from the beginning of |data| and interpreting it as a bitmask
24 // over the RTPExtensionType enum. That byte shouldn't also be part
25 // of the packet, so we adjust |data| and |size| to remove it.
26 std::bitset<8> extensionMask(data[0]);
27 data++;
28 size--;
29
30 RtpPacketReceived::ExtensionManager extensions;
31 for (int i = 0; i < kNumberOfRtpHeaderExtensions; i++) {
32 // Skip i=0 which is kRtpExtensionNone i.e. not an actual extension.
33 if (extensionMask[i + 1]) {
34 // We use i as the ID; it's used in negotiation so not relevant.
35 extensions.Register(static_cast<RTPExtensionType>(i), i);
danilchap 2016/06/15 10:16:33 valid ids for an extension is in range 1-14, i.e.
katrielc1 2016/06/15 13:22:48 Done.
36 }
37 }
38
39 RTPHeader rtp_header;
40 RtpUtility::RtpHeaderParser rtp_parser(data, size);
41 rtp_parser.Parse(&rtp_header, &extensions);
42 }
43 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/test/fuzzers/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698