Skip to content

Update Mbed CoAP to v5.1.7 #13607

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

Merged
merged 1 commit into from
Sep 29, 2020
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions connectivity/libraries/mbed-coap/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## [v5.1.7](https://github.com/ARMmbed/mbed-coap/releases/tag/v5.1.7)

- Removed comparison of IP addresses when validating message resending. This avoids unnessary network errors due to load balancers causing frequent IP address changes.

## [v5.1.6](https://github.com/ARMmbed/mbed-coap/releases/tag/v5.1.6)

- Multiple fixes for out-ouf-bounds memory accesses, a memory leak and an infinite loop condition in packet parser.
Expand Down
22 changes: 8 additions & 14 deletions connectivity/libraries/mbed-coap/source/sn_coap_protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ static uint32_t sn_coap_calculate_new_resend_time(const uint32_t cu
static uint16_t read_packet_msg_id(const coap_send_msg_s *stored_msg);
static uint16_t get_new_message_id(void);

static bool compare_address_and_port(const sn_nsdl_addr_s* left, const sn_nsdl_addr_s* right);
static bool compare_port(const sn_nsdl_addr_s* left, const sn_nsdl_addr_s* right);

/* * * * * * * * * * * * * * * * * */
/* * * * GLOBAL DECLARATIONS * * * */
Expand Down Expand Up @@ -829,10 +829,8 @@ sn_coap_hdr_s *sn_coap_protocol_parse(struct coap_s *handle, sn_nsdl_addr_s *src

/* Get node count i.e. count of active resending messages */
uint16_t stored_resending_msgs_count = handle->count_resent_msgs;

/* Check if there is ongoing active message resendings */
if (stored_resending_msgs_count > 0) {

/* Remove resending message from active message resending Linked list, if any exists */
sn_coap_protocol_linked_list_send_msg_remove(handle, src_addr_ptr, returned_dst_coap_msg_ptr->msg_id);
}
Expand Down Expand Up @@ -1013,13 +1011,12 @@ static void sn_coap_protocol_linked_list_send_msg_remove(struct coap_s *handle,
ns_list_foreach(coap_send_msg_s, stored_msg_ptr, &handle->linked_list_resent_msgs) {
/* Get message ID from stored resending message */
uint16_t temp_msg_id = read_packet_msg_id(stored_msg_ptr);

/* If message's Message ID is same than is searched */
if (temp_msg_id == msg_id) {
/* If message's Source address and port is same than is searched */
if (compare_address_and_port(src_addr_ptr, &stored_msg_ptr->send_msg_ptr.dst_addr_ptr)) {
/* * * Message found * * */

if (compare_port(src_addr_ptr, &stored_msg_ptr->send_msg_ptr.dst_addr_ptr)) {
/* * * Message found * * */
/* Remove message from Linked list */
ns_list_remove(&handle->linked_list_resent_msgs, stored_msg_ptr);
--handle->count_resent_msgs;
Expand Down Expand Up @@ -1142,7 +1139,7 @@ static coap_duplication_info_s* sn_coap_protocol_linked_list_duplication_info_se
/* If message's Message ID is same than is searched */
if (stored_duplication_info_ptr->msg_id == msg_id) {
/* If message's Source address & port is same than is searched */
if (compare_address_and_port(addr_ptr, stored_duplication_info_ptr->address)) {
if (compare_port(addr_ptr, stored_duplication_info_ptr->address)) {
/* * * Correct Duplication info found * * * */
return stored_duplication_info_ptr;
}
Expand Down Expand Up @@ -1911,7 +1908,7 @@ static sn_coap_hdr_s *sn_coap_handle_blockwise_message(struct coap_s *handle, sn
// Response with COAP_MSG_CODE_RESPONSE_REQUEST_ENTITY_TOO_LARGE if the payload size is more than we can handle
if (received_coap_msg_ptr->options_list_ptr->size1 > SN_COAP_MAX_INCOMING_BLOCK_MESSAGE_SIZE) {
// Include maximum size that stack can handle into response
tr_error("sn_coap_handle_blockwise_message - (recv block1) COAP_MSG_CODE_RESPONSE_REQUEST_ENTITY_TOO_LARGE!");
tr_info("sn_coap_handle_blockwise_message - (recv block1) entity too large");
src_coap_blockwise_ack_msg_ptr->msg_code = COAP_MSG_CODE_RESPONSE_REQUEST_ENTITY_TOO_LARGE;
}
else {
Expand All @@ -1924,7 +1921,7 @@ static sn_coap_hdr_s *sn_coap_handle_blockwise_message(struct coap_s *handle, sn

if (block_size > handle->sn_coap_block_data_size) {
// Include maximum size that stack can handle into response
tr_error("sn_coap_handle_blockwise_message - (recv block1) COAP_MSG_CODE_RESPONSE_REQUEST_ENTITY_TOO_LARGE!");
tr_info("sn_coap_handle_blockwise_message - (recv block1) entity too large");
src_coap_blockwise_ack_msg_ptr->msg_code = COAP_MSG_CODE_RESPONSE_REQUEST_ENTITY_TOO_LARGE;
src_coap_blockwise_ack_msg_ptr->options_list_ptr->size1 = handle->sn_coap_block_data_size;
}
Expand Down Expand Up @@ -2521,14 +2518,11 @@ void *sn_coap_protocol_calloc(struct coap_s *handle, uint16_t length)
return result;
}

static bool compare_address_and_port(const sn_nsdl_addr_s* left, const sn_nsdl_addr_s* right)
static bool compare_port(const sn_nsdl_addr_s* left, const sn_nsdl_addr_s* right)
{
bool match = false;

if (left->port == right->port) {
if (0 == memcmp(left->addr_ptr, right->addr_ptr, left->addr_len)) {
match = true;
}
match = true;
}

return match;
Expand Down