OSDN Git Service

Fix wrong calculation for number of elements of a data list
authorVinicius Costa Gomes <vinicius.gomes@openbossa.org>
Thu, 29 Jul 2010 20:07:36 +0000 (17:07 -0300)
committerJohan Hedberg <johan.hedberg@nokia.com>
Mon, 9 Aug 2010 22:06:47 +0000 (18:06 -0400)
We must take into account that the opcode and the length of each element is
included in each PDU.

attrib/att.c

index 281cd35..140e231 100644 (file)
@@ -174,7 +174,7 @@ struct att_data_list *dec_read_by_grp_resp(const uint8_t *pdu, int len)
 
        list = malloc(sizeof(struct att_data_list));
        list->len = pdu[1];
-       list->num = len / list->len;
+       list->num = (len - 2) / list->len;
 
        list->data = malloc(sizeof(uint8_t *) * list->num);
        ptr = &pdu[2];
@@ -282,7 +282,7 @@ struct att_data_list *dec_read_by_type_resp(const uint8_t *pdu, int len)
 
        list = malloc(sizeof(struct att_data_list));
        list->len = pdu[1];
-       list->num = len / list->len;
+       list->num = (len - 2) / list->len;
 
        list->data = malloc(sizeof(uint8_t *) * list->num);
        ptr = &pdu[2];