Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix fuzzer #2710

Merged
merged 1 commit into from
Apr 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading