Fuzz-test mg_http_var and base64

This commit is contained in:
cpq committed 2020-12-07 18:52:40 +00:00
1 parent 228acefa36
commit d1b8f9e01f
4 files changed
+13 -45

No files matched your search

+8
View File
@@ -8,11 +8,19 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
struct mg_http_message hm;
mg_http_parse((const char *) data, size, &hm);
struct mg_str body = mg_str_n((const char *) data, size);
char tmp[256];
mg_http_get_var(&body, "key", tmp, sizeof(tmp));
struct mg_mqtt_message mm;
mg_mqtt_parse(data, size, &mm);
struct timeval tv;
mg_sntp_parse(data, size, &tv);
char buf[size * 4 / 3 + 5]; // At least 4 chars and nul termination
mg_base64_decode((char *) data, size, buf);
mg_base64_encode(data, size, buf);
return 0;
}