mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-02 16:05:50 +03:00
[OSS-Fuzz] pdu_parse_target.c: Check result of coap_pdu_parse()
When coap_pdu_parse() returns 0, the contents of pdu are undefined and must not be processed. This change proceeds fuzzer tests only if parsing succeeded. Fixes OSS-Fuzz issue 44503 [1] [1] https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=44503
This commit is contained in:
1 parent
a2e0046c80
commit
ba585f848f
1 file changed
+8
-7
@@ -8,14 +8,15 @@ 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(LOG_DEBUG);
|
||||
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(LOG_DEBUG, pdu);
|
||||
coap_pdu_encode_header(pdu, COAP_PROTO_UDP);
|
||||
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(LOG_DEBUG, pdu);
|
||||
coap_pdu_encode_header(pdu, COAP_PROTO_UDP);
|
||||
|
||||
coap_delete_string(query);
|
||||
coap_delete_string(uri_path);
|
||||
coap_delete_string(query);
|
||||
coap_delete_string(uri_path);
|
||||
}
|
||||
coap_delete_pdu(pdu);
|
||||
}
|
||||
return 0;
|
||||
|
||||
Reference in new issue
Block a user