* [PATCH] Attrib server should truncate attribute value to pdu length
@ 2010-11-29 12:44 Sheldon Demario
2010-11-29 17:25 ` Johan Hedberg
0 siblings, 1 reply; 2+ messages in thread
From: Sheldon Demario @ 2010-11-29 12:44 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Sheldon Demario
When the size of attribute value is greater than pdu size, it should be
truncated to the pdu length - 2
---
attrib/att.c | 15 +++++++--------
1 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/attrib/att.c b/attrib/att.c
index 8655e5e..445b192 100644
--- a/attrib/att.c
+++ b/attrib/att.c
@@ -379,7 +379,7 @@ uint16_t dec_read_by_type_req(const uint8_t *pdu, int len, uint16_t *start,
uint16_t enc_read_by_type_resp(struct att_data_list *list, uint8_t *pdu, int len)
{
uint8_t *ptr;
- int i, w;
+ int i, w, l;
if (list == NULL)
return 0;
@@ -387,17 +387,16 @@ uint16_t enc_read_by_type_resp(struct att_data_list *list, uint8_t *pdu, int len
if (pdu == NULL)
return 0;
- if (len < list->len + 2)
- return 0;
+ l = MIN(len - 2, list->len);
pdu[0] = ATT_OP_READ_BY_TYPE_RESP;
- pdu[1] = list->len;
+ pdu[1] = l;
ptr = &pdu[2];
- for (i = 0, w = 2; i < list->num && w + list->len <= len; i++) {
- memcpy(ptr, list->data[i], list->len);
- ptr += list->len;
- w += list->len;
+ for (i = 0, w = 2; i < list->num && w + l <= len; i++) {
+ memcpy(ptr, list->data[i], l);
+ ptr += l;
+ w += l;
}
return w;
--
1.7.3.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Attrib server should truncate attribute value to pdu length
2010-11-29 12:44 [PATCH] Attrib server should truncate attribute value to pdu length Sheldon Demario
@ 2010-11-29 17:25 ` Johan Hedberg
0 siblings, 0 replies; 2+ messages in thread
From: Johan Hedberg @ 2010-11-29 17:25 UTC (permalink / raw)
To: Sheldon Demario; +Cc: linux-bluetooth
Hi Sheldon,
On Mon, Nov 29, 2010, Sheldon Demario wrote:
> When the size of attribute value is greater than pdu size, it should be
> truncated to the pdu length - 2
> ---
> attrib/att.c | 15 +++++++--------
> 1 files changed, 7 insertions(+), 8 deletions(-)
Pushed upstream. Thanks.
Johan
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-11-29 17:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-29 12:44 [PATCH] Attrib server should truncate attribute value to pdu length Sheldon Demario
2010-11-29 17:25 ` Johan Hedberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox