summaryrefslogtreecommitdiff
path: root/vendor/qoi/ext/qoi/qoifuzz.c
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/qoi/ext/qoi/qoifuzz.c')
-rw-r--r--vendor/qoi/ext/qoi/qoifuzz.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/vendor/qoi/ext/qoi/qoifuzz.c b/vendor/qoi/ext/qoi/qoifuzz.c
new file mode 100644
index 0000000..1b5c792
--- /dev/null
+++ b/vendor/qoi/ext/qoi/qoifuzz.c
@@ -0,0 +1,51 @@
+/*
+
+clang fuzzing harness for qoi_decode
+
+Compile and run with:
+ clang -fsanitize=address,fuzzer -g -O0 qoifuzz.c && ./a.out
+
+Dominic Szablewski - https://phoboslab.org
+
+
+-- LICENSE: The MIT License(MIT)
+
+Copyright(c) 2021 Dominic Szablewski
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files(the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions :
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
+*/
+
+
+#define QOI_IMPLEMENTATION
+#include "qoi.h"
+#include <stddef.h>
+#include <stdint.h>
+
+int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
+ int w, h;
+ if (size < 4) {
+ return 0;
+ }
+
+ qoi_desc desc;
+ void* decoded = qoi_decode((void*)(data + 4), (int)(size - 4), &desc, *((int *)data));
+ if (decoded != NULL) {
+ free(decoded);
+ }
+ return 0;
+}