From: hyuna0213.jo Date: Tue, 15 Mar 2016 05:58:46 +0000 (+0900) Subject: fixed the bug related to coap over tcp pdu creation. X-Git-Tag: 1.2.0+RC1~355^2^2~179 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=417ac656bad3f3c84f5cbbc8a4c88b5426a4fe1d;p=platform%2Fupstream%2Fiotivity.git fixed the bug related to coap over tcp pdu creation. The first nibble of the frame is used to indecate the length of the options/payload. and if a value is 13, an 8-bit unsigned integer follows the initial byte and indicates the length of options/payload minus 13. even in case the length of options/payload is 13, an 8-bit unsigned interger has to be used to indicate 0. Change-Id: I580e126755ae4b3018fe7eb11eae34035b0efa6c Signed-off-by: hyuna0213.jo Reviewed-on: https://gerrit.iotivity.org/gerrit/5901 Tested-by: jenkins-iotivity Reviewed-by: Jee Hyeok Kim --- diff --git a/resource/csdk/connectivity/lib/libcoap-4.1.1/pdu.c b/resource/csdk/connectivity/lib/libcoap-4.1.1/pdu.c index 7c5c993..1da4034 100644 --- a/resource/csdk/connectivity/lib/libcoap-4.1.1/pdu.c +++ b/resource/csdk/connectivity/lib/libcoap-4.1.1/pdu.c @@ -15,6 +15,7 @@ #include #include #include +#include #ifdef HAVE_ARPA_INET_H #include #endif @@ -262,22 +263,24 @@ size_t coap_get_total_message_length(const unsigned char *data, size_t size) coap_transport_type coap_get_tcp_header_type_from_size(unsigned int size) { - if (COAP_TCP_LENGTH_FIELD_8_BIT < size && COAP_TCP_LENGTH_FIELD_16_BIT >= size) + if (size < COAP_TCP_LENGTH_FIELD_8_BIT) + { + return coap_tcp; + } + else if (size < COAP_TCP_LENGTH_FIELD_16_BIT) { return coap_tcp_8bit; } - else if (COAP_TCP_LENGTH_FIELD_16_BIT < size && COAP_TCP_LENGTH_FIELD_32_BIT >= size) + else if (size < COAP_TCP_LENGTH_FIELD_32_BIT) { return coap_tcp_16bit; } - else if (COAP_TCP_LENGTH_FIELD_32_BIT < size) + else if (size < ULONG_MAX + COAP_TCP_LENGTH_FIELD_32_BIT) { return coap_tcp_32bit; } - else - { - return coap_tcp; - } + + return -1; } coap_transport_type coap_get_tcp_header_type_from_initbyte(unsigned int length)