Skip to content

Commit

Permalink
Coverity-Scan: Fix CID 1599559-1599562
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdeep1 committed Sep 4, 2024
1 parent abd0a02 commit 1365a14
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions examples/coap-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -1826,6 +1826,7 @@ cmdline_proxy(char *arg) {
}
forward_proxy.type = COAP_PROXY_FORWARD;
} else {
memset(&uri, 0, sizeof(uri));
forward_proxy.type = COAP_PROXY_DIRECT_STRIP;
}

Expand Down
9 changes: 6 additions & 3 deletions src/coap_proxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ coap_proxy_get_ongoing_session(coap_session_t *session,
proxy_entry->ongoing =
coap_new_client_session_oscore_pki_lkd(context, NULL, &dst,
proto, server_use->dtls_pki, server_use->oscore_conf);
} else if (server_use->dtls_pki) {
} else if (server_use->dtls_cpsk) {
server_use->dtls_cpsk->client_sni = client_sni;
proxy_entry->ongoing =
coap_new_client_session_oscore_psk_lkd(context, NULL, &dst,
Expand Down Expand Up @@ -549,7 +549,7 @@ coap_proxy_forward_request_lkd(coap_session_t *session,
size_t total;
coap_binary_t *body_data = NULL;
const uint8_t *data;
coap_pdu_t *pdu;
coap_pdu_t *pdu = NULL;
coap_bin_const_t r_token = coap_pdu_get_token(request);
uint8_t token[8];
size_t token_len;
Expand Down Expand Up @@ -613,7 +613,6 @@ coap_proxy_forward_request_lkd(coap_session_t *session,
}

if (!coap_add_token(pdu, token_len, token)) {
coap_delete_pdu(pdu);
goto failed;
}

Expand Down Expand Up @@ -687,6 +686,7 @@ coap_proxy_forward_request_lkd(coap_session_t *session,
}

if (coap_send_lkd(proxy_entry->ongoing, pdu) == COAP_INVALID_MID) {
pdu = NULL;
coap_log_debug("proxy: upstream PDU send error\n");
goto failed;
}
Expand All @@ -700,6 +700,7 @@ coap_proxy_forward_request_lkd(coap_session_t *session,

failed:
response->code = COAP_RESPONSE_CODE(500);
coap_delete_pdu(pdu);
return 0;
}

Expand Down Expand Up @@ -841,6 +842,7 @@ coap_proxy_forward_response_lkd(coap_session_t *session,
media_type, maxage, etag, size, data,
coap_proxy_release_body_data,
body_data);
body_data = NULL;
coap_delete_string(l_query);
}

Expand All @@ -862,6 +864,7 @@ coap_proxy_forward_response_lkd(coap_session_t *session,
(proxy_entry->req_count-j) * sizeof(proxy_entry->req_list[0]));
}
}
coap_delete_binary(body_data);
return COAP_RESPONSE_OK;
}

Expand Down

0 comments on commit 1365a14

Please sign in to comment.