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

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

Issue 2072473002: Update the current RTP parser fuzzer to handle header extensions. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Use enum value for # extensions 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 | « 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 /* 1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10
10 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_received.h" 11 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_received.h"
12 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extension.h"
13 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extensions.h"
11 14
12 namespace webrtc { 15 namespace webrtc {
16 void FuzzOneInput(const uint8_t* data, size_t size) {
17 if (size <= 1)
18 return;
13 19
14 void FuzzOneInput(const uint8_t* data, size_t size) { 20 // We decide which header extensions to register by reading one byte
danilchap 2016/06/27 11:06:17 The way parsing is written, registering all extens
katrielc 2016/07/04 07:15:31 What about an out-of-bounds read that reads too fa
danilchap 2016/07/04 08:43:55 I'm not sure how not registering extension can hel
15 RtpPacketReceived packet; 21 // from the beginning of |data| and interpreting it as a bitmask
22 // over the RTPExtensionType enum. That byte shouldn't also be part
23 // of the packet, so we adjust |data| and |size| to remove it.
24 std::bitset<8> extensionMask(data[0]);
25 data++;
26 size--;
16 27
28 RtpPacketReceived::ExtensionManager extensions;
pbos-webrtc 2016/06/26 21:49:59 Make a compile-time assert on kRtpExtensionNumberO
katrielc 2016/07/04 07:15:31 Done.
29 for (int i = 1; i < kRtpExtensionNumberOfExtensions; i++) {
30 // Skip i=0 which is kRtpExtensionNone i.e. not an actual extension.
pbos-webrtc 2016/06/26 21:49:59 From zero, but skip if it's kRtpExtensionNone expl
katrielc 2016/07/04 07:15:31 Done.
31 if (extensionMask[i]) {
32 // We use i as the ID; it's used in negotiation so not relevant.
33 extensions.Register(static_cast<RTPExtensionType>(i), i);
34 }
35 }
36
37 RtpPacketReceived packet(&extensions);
17 packet.Parse(data, size); 38 packet.Parse(data, size);
18 39
19 // Call packet accessors because they have extra checks. 40 // Call packet accessors because they have extra checks.
20 packet.Marker(); 41 packet.Marker();
21 packet.PayloadType(); 42 packet.PayloadType();
22 packet.SequenceNumber(); 43 packet.SequenceNumber();
23 packet.Timestamp(); 44 packet.Timestamp();
24 packet.Ssrc(); 45 packet.Ssrc();
25 packet.Csrcs(); 46 packet.Csrcs();
47
48 // Each extension has its own getter. Call all the ones we registered above.
pbos-webrtc 2016/06/26 21:49:59 Should this have defined behavior on non-registere
danilchap 2016/06/27 11:06:17 Yes. both for non-registered and non-present exten
katrielc 2016/07/04 07:15:31 Acknowledged.
49 for (int i = 1; i < kRtpExtensionNumberOfExtensions; i++) {
50 if (extensionMask[i]) {
51 switch (i) {
pbos-webrtc 2016/06/26 21:49:59 cast to RTPExtensionType here instead of to int be
katrielc 2016/07/04 07:15:31 Done.
52 case (int)kRtpExtensionTransmissionTimeOffset:
53 int32_t offset;
54 packet.GetExtension<TransmissionOffset>(&offset);
55 break;
56 case (int)kRtpExtensionAudioLevel:
57 bool voice_activity;
58 uint8_t audio_level;
59 packet.GetExtension<AudioLevel>(&voice_activity, &audio_level);
60 break;
61 case (int)kRtpExtensionAbsoluteSendTime:
62 uint32_t sendtime;
63 packet.GetExtension<AbsoluteSendTime>(&sendtime);
64 break;
65 case (int)kRtpExtensionVideoRotation:
66 uint8_t rotation;
67 packet.GetExtension<VideoOrientation>(&rotation);
68 break;
69 case (int)kRtpExtensionTransportSequenceNumber:
70 uint16_t seqnum;
71 packet.GetExtension<TransportSequenceNumber>(&seqnum);
72 break;
73 case (int)kRtpExtensionPlayoutDelay:
74 // TODO(danilchap) Add this once it's written.
pbos-webrtc 2016/06/26 21:49:59 TODO(katrielc):
katrielc 2016/07/04 07:15:31 Done, though I'm leaving in two weeks...
danilchap 2016/07/04 08:43:55 That doesn't matter here: TODO name the person who
75 break;
76 default:
77 break;
pbos-webrtc 2016/06/26 21:49:59 Remove default, or assert false on it.
katrielc 2016/07/04 07:15:31 Done.
78 }
79 }
80 }
26 } 81 }
27
28 } // namespace webrtc 82 } // namespace webrtc
29
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