Added MessagePack fuzzing

This commit is contained in:
Benoit Blanchon
2018-06-07 10:36:57 +02:00
parent 4ff6809bc5
commit a9a730fd74
41 changed files with 74 additions and 48 deletions
+7 -4
View File
@@ -5,15 +5,18 @@ CXXFLAGS += -I../src
all: \
$(OUT)/json_fuzzer \
$(OUT)/json_fuzzer_seed_corpus.zip \
$(OUT)/json_fuzzer.options
$(OUT)/json_fuzzer.options \
$(OUT)/msgpack_fuzzer \
$(OUT)/msgpack_fuzzer_seed_corpus.zip \
$(OUT)/msgpack_fuzzer.options
$(OUT)/json_fuzzer: fuzzer.cpp $(shell find ../src -type f)
$(OUT)/%_fuzzer: %_fuzzer.cpp $(shell find ../src -type f)
$(CXX) $(CXXFLAGS) $< -o$@ $(LIB_FUZZING_ENGINE)
$(OUT)/json_fuzzer_seed_corpus.zip: seed_corpus/*
$(OUT)/%_fuzzer_seed_corpus.zip: %_seed_corpus/*
zip -j $@ $?
$(OUT)/json_fuzzer.options:
$(OUT)/%_fuzzer.options:
@echo "[libfuzzer]" > $@
@echo "max_len = 256" >> $@
@echo "timeout = 10" >> $@
-27
View File
@@ -1,27 +0,0 @@
#include <ArduinoJson.h>
class memstream : public std::istream {
struct membuf : std::streambuf {
membuf(const uint8_t *p, size_t l) {
setg((char *)p, (char *)p, (char *)p + l);
}
};
membuf _buffer;
public:
memstream(const uint8_t *p, size_t l)
: std::istream(&_buffer), _buffer(p, l) {
rdbuf(&_buffer);
}
};
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
DynamicJsonDocument doc;
memstream json(data, size);
DeserializationError error = deserializeJson(doc, json);
if (error == DeserializationError::Ok) {
JsonVariant variant = doc.as<JsonVariant>();
variant.as<std::string>(); // <- serialize to JSON
}
return 0;
}
+11
View File
@@ -0,0 +1,11 @@
#include <ArduinoJson.h>
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
DynamicJsonDocument doc;
DeserializationError error = deserializeJson(doc, data, size);
if (!error) {
std::string json;
serializeJson(doc, json);
}
return 0;
}
+2
View File
@@ -0,0 +1,2 @@
*
!.gitignore
+11
View File
@@ -0,0 +1,11 @@
#include <ArduinoJson.h>
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
DynamicJsonDocument doc;
DeserializationError error = deserializeMsgPack(doc, data, size);
if (!error) {
std::string json;
serializeMsgPack(doc, json);
}
return 0;
}
Binary file not shown.
Binary file not shown.
+1
View File
@@ -0,0 +1 @@
�
+1
View File
@@ -0,0 +1 @@
’¥hello¥world
@@ -0,0 +1 @@
�
@@ -0,0 +1 @@

+1
View File
@@ -0,0 +1 @@
‚£one£two
+1
View File
@@ -0,0 +1 @@
«hello world
+1
View File
@@ -0,0 +1 @@
ハ@H�
+1
View File
@@ -0,0 +1 @@
Л@ !КАѓo
+1
View File
@@ -0,0 +1 @@
拮�
+1
View File
@@ -0,0 +1 @@
Ҷi�.
+1
View File
@@ -0,0 +1 @@
モ4Vx埔゙�
+1
View File
@@ -0,0 +1 @@
��
Binary file not shown.
Binary file not shown.
+1
View File
@@ -0,0 +1 @@
�
Binary file not shown.
Binary file not shown.
+1
View File
@@ -0,0 +1 @@
Ùhello
+1
View File
@@ -0,0 +1 @@
�
+1
View File
@@ -0,0 +1 @@
�09
+1
View File
@@ -0,0 +1 @@
�4Vx
+1
View File
@@ -0,0 +1 @@
マ4Vx埔゙�
+1
View File
@@ -0,0 +1 @@
��