mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-09 02:32:53 +03:00
oss-fuzz: Parse PDUs for TCP and WebSockets
This commit is contained in:
1 parent
964bd69481
commit
8ccde068ad
3 files changed
+48
-2
No files matched your search
@@ -0,0 +1,23 @@
|
||||
#include <coap3/coap.h>
|
||||
|
||||
/* Declare prototype for internal function coap_pdu_encode_header() */
|
||||
size_t coap_pdu_encode_header(coap_pdu_t *, coap_proto_t);
|
||||
|
||||
int
|
||||
LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||
coap_pdu_t *pdu = coap_pdu_init(0, 0, 0, size);
|
||||
if (pdu) {
|
||||
coap_set_log_level(COAP_LOG_ERR);
|
||||
if (coap_pdu_parse(COAP_PROTO_TCP, data, size, pdu)) {
|
||||
coap_string_t *query = coap_get_query(pdu);
|
||||
coap_string_t *uri_path = coap_get_uri_path(pdu);
|
||||
coap_show_pdu(COAP_LOG_ERR, pdu);
|
||||
coap_pdu_encode_header(pdu, COAP_PROTO_TCP);
|
||||
|
||||
coap_delete_string(query);
|
||||
coap_delete_string(uri_path);
|
||||
}
|
||||
coap_delete_pdu(pdu);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -7,11 +7,11 @@ int
|
||||
LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||
coap_pdu_t *pdu = coap_pdu_init(0, 0, 0, size);
|
||||
if (pdu) {
|
||||
coap_set_log_level(COAP_LOG_DEBUG);
|
||||
coap_set_log_level(COAP_LOG_ERR);
|
||||
if (coap_pdu_parse(COAP_PROTO_UDP, data, size, pdu)) {
|
||||
coap_string_t *query = coap_get_query(pdu);
|
||||
coap_string_t *uri_path = coap_get_uri_path(pdu);
|
||||
coap_show_pdu(COAP_LOG_DEBUG, pdu);
|
||||
coap_show_pdu(COAP_LOG_ERR, pdu);
|
||||
coap_pdu_encode_header(pdu, COAP_PROTO_UDP);
|
||||
|
||||
coap_delete_string(query);
|
||||
@@ -0,0 +1,23 @@
|
||||
#include <coap3/coap.h>
|
||||
|
||||
/* Declare prototype for internal function coap_pdu_encode_header() */
|
||||
size_t coap_pdu_encode_header(coap_pdu_t *, coap_proto_t);
|
||||
|
||||
int
|
||||
LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||
coap_pdu_t *pdu = coap_pdu_init(0, 0, 0, size);
|
||||
if (pdu) {
|
||||
coap_set_log_level(COAP_LOG_ERR);
|
||||
if (coap_pdu_parse(COAP_PROTO_WS, data, size, pdu)) {
|
||||
coap_string_t *query = coap_get_query(pdu);
|
||||
coap_string_t *uri_path = coap_get_uri_path(pdu);
|
||||
coap_show_pdu(COAP_LOG_ERR, pdu);
|
||||
coap_pdu_encode_header(pdu, COAP_PROTO_WS);
|
||||
|
||||
coap_delete_string(query);
|
||||
coap_delete_string(uri_path);
|
||||
}
|
||||
coap_delete_pdu(pdu);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user