aboutsummaryrefslogtreecommitdiffstats
path: root/util/generic/fuzz
diff options
context:
space:
mode:
authorDevtools Arcadia <arcadia-devtools@yandex-team.ru>2022-02-07 18:08:42 +0300
committerDevtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net>2022-02-07 18:08:42 +0300
commit1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch)
treee26c9fed0de5d9873cce7e00bc214573dc2195b7 /util/generic/fuzz
downloadydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'util/generic/fuzz')
-rw-r--r--util/generic/fuzz/vector/main.cpp47
-rw-r--r--util/generic/fuzz/vector/ya.make13
-rw-r--r--util/generic/fuzz/ya.make3
3 files changed, 63 insertions, 0 deletions
diff --git a/util/generic/fuzz/vector/main.cpp b/util/generic/fuzz/vector/main.cpp
new file mode 100644
index 0000000000..0a0293f795
--- /dev/null
+++ b/util/generic/fuzz/vector/main.cpp
@@ -0,0 +1,47 @@
+#include <util/generic/vector.h>
+#include <util/stream/mem.h>
+
+template <class T>
+static inline T Read(IInputStream& in) {
+ T t;
+
+ in.LoadOrFail(&t, sizeof(t));
+
+ return t;
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const ui8* data, size_t size) {
+ TMemoryInput mi(data, size);
+
+ try {
+ TVector<ui16> v;
+
+ while (mi.Avail()) {
+ char cmd = Read<char>(mi);
+
+ switch (cmd % 2) {
+ case 0: {
+ const size_t cnt = 1 + Read<ui8>(mi) % 16;
+
+ for (size_t i = 0; i < cnt; ++i) {
+ v.push_back(i);
+ }
+
+ break;
+ }
+
+ case 1: {
+ if (v) {
+ v.pop_back();
+ }
+
+ break;
+ }
+ }
+ }
+ } catch (...) {
+ // ¯\_(ツ)_/¯
+ }
+
+ return 0; // Non-zero return values are reserved for future use.
+}
diff --git a/util/generic/fuzz/vector/ya.make b/util/generic/fuzz/vector/ya.make
new file mode 100644
index 0000000000..b8614f6411
--- /dev/null
+++ b/util/generic/fuzz/vector/ya.make
@@ -0,0 +1,13 @@
+FUZZ()
+
+OWNER(
+ pg
+ g:util
+)
+SUBSCRIBER(g:util-subscribers)
+
+SRCS(
+ main.cpp
+)
+
+END()
diff --git a/util/generic/fuzz/ya.make b/util/generic/fuzz/ya.make
new file mode 100644
index 0000000000..dc60b12a0c
--- /dev/null
+++ b/util/generic/fuzz/ya.make
@@ -0,0 +1,3 @@
+RECURSE(
+ vector
+)