Skip to content

Commit 50b3418

Browse files
authored
Merge pull request #4025 from ARMmbed/release-candidate
Release candidate for mbed-os-5.4.2
2 parents f4864dc + 0edca5a commit 50b3418

File tree

1,044 files changed

+243972
-37794
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,044 files changed

+243972
-37794
lines changed

TESTS/mbed_hal/flash/functional_tests/main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ static void erase_range(flash_t *flash, uint32_t addr, uint32_t size)
4949
TEST_ASSERT_NOT_EQUAL(0, sector_size);
5050
int32_t ret = flash_erase_sector(flash, addr);
5151
TEST_ASSERT_EQUAL_INT32(0, ret);
52+
addr += sector_size;
5253
size = size > sector_size ? size - sector_size : 0;
5354
}
5455
}

drivers/I2C.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ class I2C {
117117
* @param repeated Repeated start, true - do not send stop at end
118118
*
119119
* @returns
120-
* 0 or non-zero - written number of bytes,
121-
* negative - I2C_ERROR_XXX status
120+
* 0 on success (ack),
121+
* non-0 on failure (nack)
122122
*/
123123
int write(int address, const char *data, int length, bool repeated = false);
124124

features/FEATURE_COMMON_PAL/mbed-coap/CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# Change Log
22

3+
## [v4.0.3](https://github.com/ARMmbed/mbed-coap/releases/tag/v4.0.3)
4+
5+
-[Full Changelog](https://github.com/ARMmbed/mbed-coap/compare/v4.0.2...v4.0.3)
6+
7+
**New feature**
8+
9+
- CoAP Protocol Confirmable resend fix and minor memory optimization (IOTMAC-328)
10+
11+
**Closed issues:**
12+
13+
- IOTCLT-1439 - stuck in while loop
14+
315
## [v4.0.0](https://github.com/ARMmbed/mbed-coap/releases/tag/v4.0.2)
416

517
**New feature**

features/FEATURE_COMMON_PAL/mbed-coap/mbed-coap/sn_coap_protocol.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ extern int8_t sn_coap_protocol_destroy(struct coap_s *handle);
8383
* In failure cases:\n
8484
* -1 = Failure in CoAP header structure\n
8585
* -2 = Failure in given pointer (= NULL)\n
86-
* -3 = Failure in Reset message\ŋ
86+
* -3 = Failure in Reset message\n
87+
* -4 = Failure in Resending message store\n
8788
* If there is not enough memory (or User given limit exceeded) for storing
8889
* resending messages, situation is ignored.
8990
*/

features/FEATURE_COMMON_PAL/mbed-coap/module.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mbed-coap",
3-
"version": "4.0.2",
3+
"version": "4.0.3",
44
"description": "COAP library",
55
"keywords": [
66
"coap",

features/FEATURE_COMMON_PAL/mbed-coap/source/include/sn_coap_header_internal.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ typedef struct sn_nsdl_transmit_ {
6464

6565
uint16_t packet_len;
6666
uint8_t *packet_ptr;
67-
uint8_t *uri_path_ptr;
68-
uint8_t uri_path_len;
6967
} sn_nsdl_transmit_s;
7068

7169
/* * * * * * * * * * * * * * * * * * * * * * */

features/FEATURE_COMMON_PAL/mbed-coap/source/sn_coap_builder.c

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -174,21 +174,16 @@ uint16_t sn_coap_builder_calc_needed_packet_data_size_2(sn_coap_hdr_s *src_coap_
174174
returned_byte_count += src_coap_msg_ptr->token_len;
175175
}
176176
/* URI PATH - Repeatable option. Length of one option is 0-255 */
177-
/* Do not add uri-path for notification message.
178-
* Uri-path is needed for cancelling observation with RESET message */
179-
if (!src_coap_msg_ptr->options_list_ptr ||
180-
(src_coap_msg_ptr->options_list_ptr &&
181-
COAP_OBSERVE_NONE == src_coap_msg_ptr->options_list_ptr->observe)) {
182-
if (src_coap_msg_ptr->uri_path_ptr != NULL) {
183-
repeatable_option_size = sn_coap_builder_options_calc_option_size(src_coap_msg_ptr->uri_path_len,
184-
src_coap_msg_ptr->uri_path_ptr, COAP_OPTION_URI_PATH);
185-
if (repeatable_option_size) {
186-
returned_byte_count += repeatable_option_size;
187-
} else {
188-
return 0;
189-
}
177+
if (src_coap_msg_ptr->uri_path_ptr != NULL) {
178+
repeatable_option_size = sn_coap_builder_options_calc_option_size(src_coap_msg_ptr->uri_path_len,
179+
src_coap_msg_ptr->uri_path_ptr, COAP_OPTION_URI_PATH);
180+
if (repeatable_option_size) {
181+
returned_byte_count += repeatable_option_size;
182+
} else {
183+
return 0;
190184
}
191185
}
186+
192187
uint16_t tempInt = 0;
193188
/* CONTENT FORMAT - An integer option, up to 2 bytes */
194189
if (src_coap_msg_ptr->content_format != COAP_CT_NONE) {
@@ -574,13 +569,8 @@ static int8_t sn_coap_builder_options_build(uint8_t **dst_packet_data_pptr, sn_c
574569
&src_coap_msg_ptr->options_list_ptr->location_path_len, COAP_OPTION_LOCATION_PATH, &previous_option_number);
575570
}
576571
/* * * * Build Uri-Path option * * * */
577-
/* Do not add uri-path for notification message.
578-
* Uri-path is needed for cancelling observation with RESET message */
579-
if (!src_coap_msg_ptr->options_list_ptr ||
580-
(src_coap_msg_ptr->options_list_ptr &&
581-
COAP_OBSERVE_NONE == src_coap_msg_ptr->options_list_ptr->observe))
582-
sn_coap_builder_options_build_add_multiple_option(dst_packet_data_pptr, &src_coap_msg_ptr->uri_path_ptr,
583-
&src_coap_msg_ptr->uri_path_len, COAP_OPTION_URI_PATH, &previous_option_number);
572+
sn_coap_builder_options_build_add_multiple_option(dst_packet_data_pptr, &src_coap_msg_ptr->uri_path_ptr,
573+
&src_coap_msg_ptr->uri_path_len, COAP_OPTION_URI_PATH, &previous_option_number);
584574

585575
/* * * * Build Content-Type option * * * */
586576
if (src_coap_msg_ptr->content_format != COAP_CT_NONE) {

features/FEATURE_COMMON_PAL/mbed-coap/source/sn_coap_parser.c

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
#include "mbed-coap/sn_coap_protocol.h"
3636
#include "sn_coap_header_internal.h"
3737
#include "sn_coap_protocol_internal.h"
38-
3938
/* * * * * * * * * * * * * * * * * * * * */
4039
/* * * * LOCAL FUNCTION PROTOTYPES * * * */
4140
/* * * * * * * * * * * * * * * * * * * * */
@@ -315,6 +314,7 @@ static int8_t sn_coap_parser_options_parse(struct coap_s *handle, uint8_t **pack
315314
(*packet_data_pptr) += 2;
316315
}
317316

317+
message_left = packet_len - (*packet_data_pptr - packet_data_start_ptr);
318318

319319
/* * * Parse option itself * * */
320320
/* Some options are handled independently in own functions */
@@ -655,7 +655,7 @@ static int16_t sn_coap_parser_options_count_needed_memory_multiple_option(uint8_
655655
uint16_t i = 1;
656656

657657
/* Loop all Uri-Query options */
658-
while (i < packet_left_len) {
658+
while (i <= packet_left_len) {
659659
if (option == COAP_OPTION_LOCATION_PATH && option_number_len > 255) {
660660
return -1;
661661
}
@@ -677,14 +677,13 @@ static int16_t sn_coap_parser_options_count_needed_memory_multiple_option(uint8_
677677

678678
i += option_number_len;
679679
ret_value += option_number_len + 1; /* + 1 is for separator */
680-
if(ret_value >= packet_left_len)
681-
break;
682-
683-
if(ret_value >= packet_left_len)
684-
break;
685680

686-
if( i == packet_left_len )
681+
if( i == packet_left_len ) {
687682
break;
683+
}
684+
else if( i > packet_left_len ) {
685+
return -1;
686+
}
688687

689688
if ((*(packet_data_ptr + i) >> COAP_OPTIONS_OPTION_NUMBER_SHIFT) != 0) {
690689
return (ret_value - 1); /* -1 because last Part path does not include separator */
@@ -693,9 +692,19 @@ static int16_t sn_coap_parser_options_count_needed_memory_multiple_option(uint8_
693692
option_number_len = (*(packet_data_ptr + i) & 0x0F);
694693

695694
if (option_number_len == 13) {
695+
696+
if(i + 1 >= packet_left_len) {
697+
return -1;
698+
}
699+
696700
i++;
697701
option_number_len = *(packet_data_ptr + i) + 13;
698702
} else if (option_number_len == 14) {
703+
704+
if(i + 2 >= packet_left_len) {
705+
return -1;
706+
}
707+
699708
option_number_len = *(packet_data_ptr + i + 2);
700709
option_number_len += (*(packet_data_ptr + i + 1) << 8) + 269;
701710
i += 2;
@@ -750,3 +759,4 @@ static int8_t sn_coap_parser_payload_parse(uint16_t packet_data_len, uint8_t *pa
750759
}
751760
return 0;
752761
}
762+

0 commit comments

Comments
 (0)