Skip to content

Commit

Permalink
gatt-server: Check pointer before memcpy
Browse files Browse the repository at this point in the history
This adds a check before calling memcpy inside
bt_gatt_server_send_notification, to avoid getting
the following error in case the user wants to send
an empty notification for an attribute:

src/shared/gatt-server.c:1789:3: runtime error:
null pointer passed as argument 2, which is declared to never be null
  • Loading branch information
iulia-tanasescu authored and Vudentz committed Jun 13, 2023
1 parent d2d2d12 commit c0156ed
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/shared/gatt-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* BlueZ - Bluetooth protocol stack for Linux
*
* Copyright (C) 2014 Google Inc.
* Copyright 2023 NXP
*
*
*/
Expand Down Expand Up @@ -1785,7 +1786,9 @@ bool bt_gatt_server_send_notification(struct bt_gatt_server *server,
length = MIN(data->len - data->offset, length);
}

memcpy(data->pdu + data->offset, value, length);
if (value)
memcpy(data->pdu + data->offset, value, length);

data->offset += length;

if (multiple) {
Expand Down

0 comments on commit c0156ed

Please sign in to comment.