Skip to content

Commit

Permalink
Merge pull request #2710 from cesanta/2650plus
Browse files Browse the repository at this point in the history
fix fuzzer
  • Loading branch information
scaprile authored Apr 18, 2024
2 parents a025577 + 0a168b6 commit 0f4ca8d
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions test/fuzz.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {

struct mg_http_message hm;
if (mg_http_parse((const char *) data, size, &hm) > 0) {
mg_crc32(0, hm.method.ptr, hm.method.len);
mg_crc32(0, hm.uri.ptr, hm.uri.len);
mg_crc32(0, hm.uri.ptr, hm.uri.len);
mg_crc32(0, hm.method.buf, hm.method.len);
mg_crc32(0, hm.uri.buf, hm.uri.len);
mg_crc32(0, hm.uri.buf, hm.uri.len);
for (size_t i = 0; i < sizeof(hm.headers) / sizeof(hm.headers[0]); i++) {
struct mg_str *k = &hm.headers[i].name, *v = &hm.headers[i].value;
mg_crc32(0, k->ptr, k->len);
mg_crc32(0, v->ptr, v->len);
mg_crc32(0, k->buf, k->len);
mg_crc32(0, v->buf, v->len);
}
}
mg_http_parse(NULL, 0, &hm);
Expand All @@ -51,15 +51,15 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {

struct mg_mqtt_message mm;
if (mg_mqtt_parse(data, size, 0, &mm) == MQTT_OK) {
mg_crc32(0, mm.topic.ptr, mm.topic.len);
mg_crc32(0, mm.data.ptr, mm.data.len);
mg_crc32(0, mm.dgram.ptr, mm.dgram.len);
mg_crc32(0, mm.topic.buf, mm.topic.len);
mg_crc32(0, mm.data.buf, mm.data.len);
mg_crc32(0, mm.dgram.buf, mm.dgram.len);
}
mg_mqtt_parse(NULL, 0, 0, &mm);
if (mg_mqtt_parse(data, size, 5, &mm) == MQTT_OK) {
mg_crc32(0, mm.topic.ptr, mm.topic.len);
mg_crc32(0, mm.data.ptr, mm.data.len);
mg_crc32(0, mm.dgram.ptr, mm.dgram.len);
mg_crc32(0, mm.topic.buf, mm.topic.len);
mg_crc32(0, mm.data.buf, mm.data.len);
mg_crc32(0, mm.dgram.buf, mm.dgram.len);
}
mg_mqtt_parse(NULL, 0, 5, &mm);

Expand Down

0 comments on commit 0f4ca8d

Please sign in to comment.