Benjamin Wright | 1295b0d | 2019-03-13 15:01:22 -0700 | [diff] [blame] | 1 | /* |
| 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 Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame] | 13 | |
Benjamin Wright | 1295b0d | 2019-03-13 15:01:22 -0700 | [diff] [blame] | 14 | #include <algorithm> |
| 15 | #include <memory> |
| 16 | #include <string> |
| 17 | |
Tommi | 25eb47c | 2019-08-29 16:39:05 +0200 | [diff] [blame^] | 18 | #include "test/rtp_header_parser.h" |
Benjamin Wright | 1295b0d | 2019-03-13 15:01:22 -0700 | [diff] [blame] | 19 | |
| 20 | namespace webrtc { |
| 21 | |
| 22 | void FuzzOneInput(const uint8_t* data, size_t size) { |
| 23 | RtpHeaderParser::IsRtcp(data, size); |
| 24 | RtpHeaderParser::GetSsrc(data, size); |
| 25 | RTPHeader rtp_header; |
| 26 | |
Tommi | 25eb47c | 2019-08-29 16:39:05 +0200 | [diff] [blame^] | 27 | std::unique_ptr<RtpHeaderParser> rtp_header_parser( |
| 28 | RtpHeaderParser::CreateForTest()); |
Benjamin Wright | 1295b0d | 2019-03-13 15:01:22 -0700 | [diff] [blame] | 29 | |
| 30 | rtp_header_parser->Parse(data, size, &rtp_header); |
| 31 | for (int i = 1; i < kRtpExtensionNumberOfExtensions; ++i) { |
| 32 | if (size > 0 && i >= data[size - 1]) { |
| 33 | RTPExtensionType add_extension = static_cast<RTPExtensionType>(i); |
| 34 | rtp_header_parser->RegisterRtpHeaderExtension(add_extension, i); |
| 35 | } |
| 36 | } |
| 37 | rtp_header_parser->Parse(data, size, &rtp_header); |
| 38 | |
| 39 | for (int i = 1; i < kRtpExtensionNumberOfExtensions; ++i) { |
| 40 | if (size > 1 && i >= data[size - 2]) { |
| 41 | RTPExtensionType remove_extension = static_cast<RTPExtensionType>(i); |
| 42 | rtp_header_parser->DeregisterRtpHeaderExtension(remove_extension); |
| 43 | } |
| 44 | } |
| 45 | rtp_header_parser->Parse(data, size, &rtp_header); |
| 46 | } |
| 47 | |
| 48 | } // namespace webrtc |