xref: /third_party/libcoap/tests/oss-fuzz/pdu_parse_ws_target.c
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/libcoap/tests/oss-fuzz/
1c87c5fbaSopenharmony_ci#include <coap3/coap.h>
2c87c5fbaSopenharmony_ci
3c87c5fbaSopenharmony_ci/* Declare prototype for internal function coap_pdu_encode_header() */
4c87c5fbaSopenharmony_cisize_t coap_pdu_encode_header(coap_pdu_t *, coap_proto_t);
5c87c5fbaSopenharmony_ci
6c87c5fbaSopenharmony_ciint
7c87c5fbaSopenharmony_ciLLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
8c87c5fbaSopenharmony_ci  coap_pdu_t *pdu = coap_pdu_init(0, 0, 0, size);
9c87c5fbaSopenharmony_ci  if (pdu) {
10c87c5fbaSopenharmony_ci    coap_set_log_level(COAP_LOG_ERR);
11c87c5fbaSopenharmony_ci    if (coap_pdu_parse(COAP_PROTO_WS, data, size, pdu)) {
12c87c5fbaSopenharmony_ci      coap_string_t *query = coap_get_query(pdu);
13c87c5fbaSopenharmony_ci      coap_string_t *uri_path = coap_get_uri_path(pdu);
14c87c5fbaSopenharmony_ci      coap_show_pdu(COAP_LOG_ERR, pdu);
15c87c5fbaSopenharmony_ci      coap_pdu_encode_header(pdu, COAP_PROTO_WS);
16c87c5fbaSopenharmony_ci
17c87c5fbaSopenharmony_ci      coap_delete_string(query);
18c87c5fbaSopenharmony_ci      coap_delete_string(uri_path);
19c87c5fbaSopenharmony_ci    }
20c87c5fbaSopenharmony_ci    coap_delete_pdu(pdu);
21c87c5fbaSopenharmony_ci  }
22c87c5fbaSopenharmony_ci  return 0;
23c87c5fbaSopenharmony_ci}
24

Indexes created Thu Nov 07 10:32:03 CST 2024