nimble/gatt: fix zero length attribute read

It is possible to read with offset equal to the length of the
attribute.

With this patch it is possible to pass GATT/SR/GAR/BV-08-C.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/118e3993
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/118e3993
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/118e3993

Branch: refs/heads/develop
Commit: 118e3993830495025c037e63b23bd3a2d319bf5b
Parents: e4231b6
Author: Michał Narajowski <[email protected]>
Authored: Tue Jan 10 13:58:19 2017 +0100
Committer: Michał Narajowski <[email protected]>
Committed: Wed Jan 18 11:12:08 2017 +0100

----------------------------------------------------------------------
 net/nimble/host/src/ble_gatts.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/118e3993/net/nimble/host/src/ble_gatts.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_gatts.c b/net/nimble/host/src/ble_gatts.c
index 4a5ddfb..f761a30 100644
--- a/net/nimble/host/src/ble_gatts.c
+++ b/net/nimble/host/src/ble_gatts.c
@@ -334,7 +334,7 @@ ble_gatts_val_access(uint16_t conn_handle, uint16_t 
attr_handle,
         rc = access_cb(conn_handle, attr_handle, gatt_ctxt, cb_arg);
         if (rc == 0) {
             attr_len = OS_MBUF_PKTLEN(gatt_ctxt->om) - offset;
-            if (attr_len > 0) {
+            if (attr_len >= 0) {
                 os_mbuf_appendfrom(*om, gatt_ctxt->om, offset, attr_len);
             } else {
                 return BLE_ATT_ERR_INVALID_OFFSET;

Reply via email to