blob: 6d95fdc2ddfc6556ee4e665c91268fd96fd8a5cc [file] [log] [blame]
Benjamin Wright1295b0d2019-03-13 15:01:22 -07001/*
2 * Copyright (c) 2019 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 <stddef.h>
12#include <stdint.h>
Jonas Olssona4d87372019-07-05 19:08:33 +020013
Benjamin Wright1295b0d2019-03-13 15:01:22 -070014#include <algorithm>
15#include <memory>
16#include <string>
17
18#include "modules/rtp_rtcp/include/rtp_header_parser.h"
19
20namespace webrtc {
21
22void FuzzOneInput(const uint8_t* data, size_t size) {
23 RtpHeaderParser::IsRtcp(data, size);
24 RtpHeaderParser::GetSsrc(data, size);
25 RTPHeader rtp_header;
26
27 std::unique_ptr<RtpHeaderParser> rtp_header_parser(RtpHeaderParser::Create());
28
29 rtp_header_parser->Parse(data, size, &rtp_header);
30 for (int i = 1; i < kRtpExtensionNumberOfExtensions; ++i) {
31 if (size > 0 && i >= data[size - 1]) {
32 RTPExtensionType add_extension = static_cast<RTPExtensionType>(i);
33 rtp_header_parser->RegisterRtpHeaderExtension(add_extension, i);
34 }
35 }
36 rtp_header_parser->Parse(data, size, &rtp_header);
37
38 for (int i = 1; i < kRtpExtensionNumberOfExtensions; ++i) {
39 if (size > 1 && i >= data[size - 2]) {
40 RTPExtensionType remove_extension = static_cast<RTPExtensionType>(i);
41 rtp_header_parser->DeregisterRtpHeaderExtension(remove_extension);
42 }
43 }
44 rtp_header_parser->Parse(data, size, &rtp_header);
45}
46
47} // namespace webrtc