diff options
author | Szymon Janc <szymon.janc@tieto.com> | 2014-04-02 16:12:56 +0200 |
---|---|---|
committer | Szymon Janc <szymon.janc@tieto.com> | 2014-04-02 16:31:09 +0200 |
commit | addb76e7d3d5fecdaca3f6f3ae4d6f02dc6b6510 (patch) | |
tree | f0b9158a1a357f526b68507424edfb5f150037a8 /android/hal-gatt.c | |
parent | 92e869f47a7bfd75c5d56b1d72318f7e42e5bbb0 (diff) | |
download | bluez-addb76e7d3d5fecdaca3f6f3ae4d6f02dc6b6510.tar.gz |
android/hal-gatt: Use fixed size buffer when passing AD to Java
HAL callback is missing length parameter and JNI code always copies
62 bytes from data.
Diffstat (limited to 'android/hal-gatt.c')
-rw-r--r-- | android/hal-gatt.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/android/hal-gatt.c b/android/hal-gatt.c index d7b3d9ab3..5e7443c89 100644 --- a/android/hal-gatt.c +++ b/android/hal-gatt.c @@ -75,15 +75,20 @@ static void handle_register_client(void *buf, uint16_t len) static void handle_scan_result(void *buf, uint16_t len) { struct hal_ev_gatt_client_scan_result *ev = buf; + uint8_t ad[62]; if (len != sizeof(*ev) + ev->len ) { error("gatt: invalid scan result event, aborting"); exit(EXIT_FAILURE); } + /* Java assumes that passed data has 62 bytes */ + memset(ad, 0, sizeof(ad)); + memcpy(ad, ev->adv_data, ev->len > sizeof(ad) ? sizeof(ad) : ev->len); + if (cbs->client->scan_result_cb) cbs->client->scan_result_cb((bt_bdaddr_t *) ev->bda, ev->rssi, - ev->adv_data); + ad); } static void handle_connect(void *buf, uint16_t len) |