webrtc-streamer 0.8.13 → 0.8.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -28
- package/cxxopts/BUILD.bazel +16 -0
- package/cxxopts/CHANGELOG.md +183 -0
- package/cxxopts/INSTALL +46 -0
- package/cxxopts/LICENSE +19 -0
- package/cxxopts/README.md +289 -0
- package/cxxopts/WORKSPACE +16 -0
- package/cxxopts/include/cxxopts.hpp +2925 -0
- package/cxxopts/packaging/cxxopts-config.cmake.in +4 -0
- package/cxxopts/packaging/pkgconfig.pc.in +9 -0
- package/cxxopts/src/example.cpp +202 -0
- package/cxxopts/test/catch.hpp +17983 -0
- package/cxxopts/test/fuzz.cpp +107 -0
- package/cxxopts/test/link_a.cpp +6 -0
- package/cxxopts/test/link_b.cpp +1 -0
- package/cxxopts/test/main.cpp +2 -0
- package/cxxopts/test/options.cpp +1193 -0
- package/package.json +1 -1
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
#include <cassert>
|
|
2
|
+
#include <cxxopts.hpp>
|
|
3
|
+
#include <fuzzer/FuzzedDataProvider.h>
|
|
4
|
+
|
|
5
|
+
constexpr int kMaxOptions = 1024;
|
|
6
|
+
constexpr int kMaxArgSize = 1024;
|
|
7
|
+
|
|
8
|
+
enum class ParseableTypes
|
|
9
|
+
{
|
|
10
|
+
kInt,
|
|
11
|
+
kString,
|
|
12
|
+
kVectorString,
|
|
13
|
+
kFloat,
|
|
14
|
+
kDouble,
|
|
15
|
+
|
|
16
|
+
// Marker for fuzzer.
|
|
17
|
+
kMaxValue,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
template <typename T>
|
|
21
|
+
void
|
|
22
|
+
add_fuzzed_option(cxxopts::Options* options, FuzzedDataProvider* provider)
|
|
23
|
+
{
|
|
24
|
+
assert(options);
|
|
25
|
+
assert(provider);
|
|
26
|
+
|
|
27
|
+
options->add_options()(provider->ConsumeRandomLengthString(kMaxArgSize),
|
|
28
|
+
provider->ConsumeRandomLengthString(kMaxArgSize),
|
|
29
|
+
cxxopts::value<T>());
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
extern "C" int
|
|
33
|
+
LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
|
34
|
+
{
|
|
35
|
+
try
|
|
36
|
+
{
|
|
37
|
+
FuzzedDataProvider provider(data, size);
|
|
38
|
+
|
|
39
|
+
// Randomly generate a usage string.
|
|
40
|
+
cxxopts::Options options(provider.ConsumeRandomLengthString(kMaxArgSize),
|
|
41
|
+
provider.ConsumeRandomLengthString(kMaxArgSize));
|
|
42
|
+
|
|
43
|
+
// Randomly generate a set of flags configurations.
|
|
44
|
+
for (int i = 0; i < provider.ConsumeIntegralInRange<int>(0, kMaxOptions);
|
|
45
|
+
i++)
|
|
46
|
+
{
|
|
47
|
+
switch (provider.ConsumeEnum<ParseableTypes>())
|
|
48
|
+
{
|
|
49
|
+
case ParseableTypes::kInt:
|
|
50
|
+
add_fuzzed_option<int>(&options, &provider);
|
|
51
|
+
break;
|
|
52
|
+
case ParseableTypes::kString:
|
|
53
|
+
add_fuzzed_option<std::string>(&options, &provider);
|
|
54
|
+
break;
|
|
55
|
+
case ParseableTypes::kVectorString:
|
|
56
|
+
add_fuzzed_option<std::vector<std::string>>(&options, &provider);
|
|
57
|
+
break;
|
|
58
|
+
case ParseableTypes::kFloat:
|
|
59
|
+
add_fuzzed_option<float>(&options, &provider);
|
|
60
|
+
break;
|
|
61
|
+
case ParseableTypes::kDouble:
|
|
62
|
+
add_fuzzed_option<double>(&options, &provider);
|
|
63
|
+
break;
|
|
64
|
+
default:
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
// Sometimes allow unrecognised options.
|
|
69
|
+
if (provider.ConsumeBool())
|
|
70
|
+
{
|
|
71
|
+
options.allow_unrecognised_options();
|
|
72
|
+
}
|
|
73
|
+
// Sometimes allow trailing positional arguments.
|
|
74
|
+
if (provider.ConsumeBool())
|
|
75
|
+
{
|
|
76
|
+
std::string positional_option_name =
|
|
77
|
+
provider.ConsumeRandomLengthString(kMaxArgSize);
|
|
78
|
+
options.add_options()(positional_option_name,
|
|
79
|
+
provider.ConsumeRandomLengthString(kMaxArgSize),
|
|
80
|
+
cxxopts::value<std::vector<std::string>>());
|
|
81
|
+
options.parse_positional({positional_option_name});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Build command line input.
|
|
85
|
+
const int argc = provider.ConsumeIntegralInRange<int>(1, kMaxOptions);
|
|
86
|
+
|
|
87
|
+
std::vector<std::string> command_line_container;
|
|
88
|
+
command_line_container.reserve(argc);
|
|
89
|
+
|
|
90
|
+
std::vector<const char*> argv;
|
|
91
|
+
argv.reserve(argc);
|
|
92
|
+
|
|
93
|
+
for (int i = 0; i < argc; i++)
|
|
94
|
+
{
|
|
95
|
+
command_line_container.push_back(
|
|
96
|
+
provider.ConsumeRandomLengthString(kMaxArgSize));
|
|
97
|
+
argv.push_back(command_line_container[i].c_str());
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Parse command line;
|
|
101
|
+
auto result = options.parse(argc, argv.data());
|
|
102
|
+
} catch (...)
|
|
103
|
+
{
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return 0;
|
|
107
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#include <cxxopts.hpp>
|