Add fuzzer for TURN unwrap.
This is called on received network packets if dump_rtp_packets_ is on.
NOTRY=true
Review-Url: https://codereview.webrtc.org/2126463002
Cr-Original-Commit-Position: refs/heads/master@{#13394}
Cr-Mirrored-From: https://chromium.googlesource.com/external/webrtc
Cr-Mirrored-Commit: 262ba77d78c2f2b718be6dab158afa69e9c7d5fe
diff --git a/test/fuzzers/BUILD.gn b/test/fuzzers/BUILD.gn
index c1b9ed9..9179d05 100644
--- a/test/fuzzers/BUILD.gn
+++ b/test/fuzzers/BUILD.gn
@@ -7,8 +7,9 @@
# be found in the AUTHORS file in the root of the source tree.
import("//build/config/features.gni")
-import("//testing/test.gni")
+import("//build_overrides/webrtc.gni")
import("//testing/libfuzzer/fuzzer_test.gni")
+import("//testing/test.gni")
static_library("webrtc_fuzzer_main") {
public_configs = [ "../..:common_inherited_config" ]
@@ -175,3 +176,17 @@
"../../modules/audio_coding:webrtc_opus",
]
}
+
+# TODO(katrielc) Enable in Chromium when CL 2022833002 lands.
+# Although the dependency on media compiles in standalone, it is
+# flagged by gn check, so breaks when rolled into Chromium.
+if (!build_with_chromium) {
+ webrtc_fuzzer_test("turn_unwrap_fuzzer") {
+ sources = [
+ "turn_unwrap_fuzzer.cc",
+ ]
+ deps = [
+ "../../media:media",
+ ]
+ }
+}
diff --git a/test/fuzzers/turn_unwrap_fuzzer.cc b/test/fuzzers/turn_unwrap_fuzzer.cc
new file mode 100644
index 0000000..818fbe9
--- /dev/null
+++ b/test/fuzzers/turn_unwrap_fuzzer.cc
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include <stddef.h>
+#include <stdint.h>
+
+#include "webrtc/media/base/turnutils.h"
+
+namespace webrtc {
+void FuzzOneInput(const uint8_t* data, size_t size) {
+ size_t content_position;
+ size_t content_size;
+ cricket::UnwrapTurnPacket(data, size, &content_position, &content_size);
+}
+} // namespace webrtc