2019-07-12 20:28:20 +08:00
|
|
|
#include "mongoose.h"
|
|
|
|
|
2020-12-14 00:56:30 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *, size_t);
|
2021-10-23 02:41:26 +08:00
|
|
|
#else
|
|
|
|
int LLVMFuzzerTestOneInput(const uint8_t *, size_t);
|
2020-12-14 00:56:30 +08:00
|
|
|
#endif
|
2020-12-05 19:26:32 +08:00
|
|
|
|
2019-07-12 20:28:20 +08:00
|
|
|
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
2022-08-01 18:19:32 +08:00
|
|
|
mg_log_set(MG_LL_NONE);
|
2022-05-07 04:09:13 +08:00
|
|
|
|
2020-12-05 19:26:32 +08:00
|
|
|
struct mg_dns_message dm;
|
|
|
|
mg_dns_parse(data, size, &dm);
|
2020-12-11 21:16:51 +08:00
|
|
|
mg_dns_parse(NULL, 0, &dm);
|
2020-12-05 19:26:32 +08:00
|
|
|
|
|
|
|
struct mg_http_message hm;
|
|
|
|
mg_http_parse((const char *) data, size, &hm);
|
2020-12-11 21:16:51 +08:00
|
|
|
mg_http_parse(NULL, 0, &hm);
|
2020-12-05 19:26:32 +08:00
|
|
|
|
2020-12-08 02:52:40 +08:00
|
|
|
struct mg_str body = mg_str_n((const char *) data, size);
|
|
|
|
char tmp[256];
|
|
|
|
mg_http_get_var(&body, "key", tmp, sizeof(tmp));
|
2020-12-14 00:33:46 +08:00
|
|
|
mg_http_get_var(&body, "key", NULL, 0);
|
2020-12-11 17:35:50 +08:00
|
|
|
mg_url_decode((char *) data, size, tmp, sizeof(tmp), 1);
|
|
|
|
mg_url_decode((char *) data, size, tmp, 1, 1);
|
2020-12-11 21:16:51 +08:00
|
|
|
mg_url_decode(NULL, 0, tmp, 1, 1);
|
2020-12-08 02:52:40 +08:00
|
|
|
|
2020-12-05 19:26:32 +08:00
|
|
|
struct mg_mqtt_message mm;
|
2022-06-28 18:31:13 +08:00
|
|
|
mg_mqtt_parse(data, size, 0, &mm);
|
|
|
|
mg_mqtt_parse(NULL, 0, 0, &mm);
|
|
|
|
mg_mqtt_parse(data, size, 5, &mm);
|
|
|
|
mg_mqtt_parse(NULL, 0, 5, &mm);
|
2020-12-05 19:26:32 +08:00
|
|
|
|
2021-12-22 05:50:18 +08:00
|
|
|
mg_sntp_parse(data, size);
|
|
|
|
mg_sntp_parse(NULL, 0);
|
2020-12-05 19:26:32 +08:00
|
|
|
|
2020-12-08 02:52:40 +08:00
|
|
|
char buf[size * 4 / 3 + 5]; // At least 4 chars and nul termination
|
2021-07-26 18:00:37 +08:00
|
|
|
mg_base64_decode((char *) data, (int) size, buf);
|
2020-12-11 21:16:51 +08:00
|
|
|
mg_base64_decode(NULL, 0, buf);
|
2021-07-26 18:00:37 +08:00
|
|
|
mg_base64_encode(data, (int) size, buf);
|
2020-12-11 21:16:51 +08:00
|
|
|
mg_base64_encode(NULL, 0, buf);
|
2020-12-08 02:52:40 +08:00
|
|
|
|
2020-12-24 17:07:55 +08:00
|
|
|
mg_globmatch((char *) data, size, (char *) data, size);
|
|
|
|
|
|
|
|
struct mg_str k, v, s = mg_str_n((char *) data, size);
|
2021-08-28 13:54:56 +08:00
|
|
|
while (mg_commalist(&s, &k, &v)) k.len = v.len = 0;
|
2020-12-24 17:07:55 +08:00
|
|
|
|
2022-06-09 19:39:48 +08:00
|
|
|
int n;
|
2022-07-30 14:55:26 +08:00
|
|
|
mg_json_get(mg_str_n((char *) data, size), "$", &n);
|
2022-06-09 19:39:48 +08:00
|
|
|
|
2019-07-12 20:28:20 +08:00
|
|
|
return 0;
|
|
|
|
}
|