diff options
author | Jakub Tyszkowski <jakub.tyszkowski@tieto.com> | 2014-12-01 13:54:06 +0100 |
---|---|---|
committer | Szymon Janc <szymon.janc@tieto.com> | 2014-12-03 12:46:08 +0100 |
commit | e31999cd81bc7bfc042413f151895820d711f6eb (patch) | |
tree | f8e1d91ae86ae27cb2953ec3f1c5c3dd0adbc2e3 /attrib | |
parent | 2841df9209b6164f2c7bee3fa3003fe3a2ef4c3d (diff) | |
download | bluez-e31999cd81bc7bfc042413f151895820d711f6eb.tar.gz |
gattrib: Fix not changing the buffer size when mtu is reduced
Using larger buffer than mtu resulted in not sending the message at all
as encode_pdu() in shared/att.c fails when provided data buffer is
larger than current mtu.
Diffstat (limited to 'attrib')
-rw-r--r-- | attrib/gattrib.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/attrib/gattrib.c b/attrib/gattrib.c index a04a0ee49..cfa3b78a3 100644 --- a/attrib/gattrib.c +++ b/attrib/gattrib.c @@ -324,11 +324,17 @@ uint8_t *g_attrib_get_buffer(GAttrib *attrib, size_t *len) gboolean g_attrib_set_mtu(GAttrib *attrib, int mtu) { - /* Clients of this expect a buffer to use. */ - if (mtu > attrib->buflen) { + /* + * Clients of this expect a buffer to use. + * + * Pdu encoding in sharred/att verifies if whole buffer fits the mtu, + * thus we should set the buflen also when mtu is reduced. But we + * need to reallocate the buffer only if mtu is larger. + */ + if (mtu > attrib->buflen) attrib->buf = g_realloc(attrib->buf, mtu); - attrib->buflen = mtu; - } + + attrib->buflen = mtu; return bt_att_set_mtu(attrib->att, mtu); } |