From f51329b85867cb3efef16da4b9624ec9620e163c Mon Sep 17 00:00:00 2001 From: Yogesh Pande Date: Thu, 23 Feb 2017 12:29:49 +0200 Subject: [PATCH] Reverting fix for IOTCLT-1439 because of regression --- .../mbed-coap/source/sn_coap_parser.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/features/FEATURE_COMMON_PAL/mbed-coap/source/sn_coap_parser.c b/features/FEATURE_COMMON_PAL/mbed-coap/source/sn_coap_parser.c index fa2b661eef..6ec7c68de4 100644 --- a/features/FEATURE_COMMON_PAL/mbed-coap/source/sn_coap_parser.c +++ b/features/FEATURE_COMMON_PAL/mbed-coap/source/sn_coap_parser.c @@ -655,7 +655,7 @@ static int16_t sn_coap_parser_options_count_needed_memory_multiple_option(uint8_ uint16_t i = 1; /* Loop all Uri-Query options */ - while (i <= packet_left_len) { + while (i < packet_left_len) { if (option == COAP_OPTION_LOCATION_PATH && option_number_len > 255) { return -1; } @@ -677,10 +677,14 @@ static int16_t sn_coap_parser_options_count_needed_memory_multiple_option(uint8_ i += option_number_len; ret_value += option_number_len + 1; /* + 1 is for separator */ - - if( i >= packet_left_len ) { + if(ret_value >= packet_left_len) + break; + + if(ret_value >= packet_left_len) + break; + + if( i == packet_left_len ) break; - } if ((*(packet_data_ptr + i) >> COAP_OPTIONS_OPTION_NUMBER_SHIFT) != 0) { return (ret_value - 1); /* -1 because last Part path does not include separator */