aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/contrib/examples/highlighter/fuzz.c
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-01-05 17:02:14 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2019-01-23 14:29:44 +0100
commit7326c8d67afbc7d53ef1dffbfe80a3efb85655a6 (patch)
treeb578c011fead38e96bebc3169209a5f9a4f19f84 /contrib/examples/highlighter/fuzz.c
parentglobal: normalize -> clamp (diff)
downloadwireguard-monolithic-historical-7326c8d67afbc7d53ef1dffbfe80a3efb85655a6.tar.xz
wireguard-monolithic-historical-7326c8d67afbc7d53ef1dffbfe80a3efb85655a6.zip
contrib: introduce simple highlighter library
Diffstat (limited to 'contrib/examples/highlighter/fuzz.c')
-rw-r--r--contrib/examples/highlighter/fuzz.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/contrib/examples/highlighter/fuzz.c b/contrib/examples/highlighter/fuzz.c
new file mode 100644
index 0000000..e308157
--- /dev/null
+++ b/contrib/examples/highlighter/fuzz.c
@@ -0,0 +1,22 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2015-2019 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include "highlighter.h"
+
+int LLVMFuzzerTestOneInput(const char *data, size_t size)
+{
+ char *str = strndup(data, size);
+ if (!str)
+ return 0;
+ struct highlight_span *spans = highlight_config(str);
+ if (!spans)
+ return 0;
+ for (struct highlight_span *span = spans; span->type != HighlightEnd; ++span);
+ free(spans);
+ free(str);
+ return 0;
+}