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
---
src/shared/gatt-server.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/shared/gatt-server.c b/src/shared/gatt-server.c
index 85cff30ec..0512d06f6 100644
--- a/src/shared/gatt-server.c
+++ b/src/shared/gatt-server.c
@@ -4,6 +4,7 @@
* BlueZ - Bluetooth protocol stack for Linux
*
* Copyright (C) 2014 Google Inc.
+ * Copyright 2023 NXP
*
*
*/
@@ -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) {
--
2.34.1
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=756771
---Test result---
Test Summary:
CheckPatch PASS 1.14 seconds
GitLint PASS 0.63 seconds
BuildEll PASS 32.29 seconds
BluezMake PASS 1020.71 seconds
MakeCheck PASS 12.55 seconds
MakeDistcheck PASS 186.31 seconds
CheckValgrind PASS 302.76 seconds
CheckSmatch WARNING 405.95 seconds
bluezmakeextell PASS 123.21 seconds
IncrementalBuild PASS 1656.48 seconds
ScanBuild PASS 1261.57 seconds
Details
##############################
Test: CheckSmatch - WARNING
Desc: Run smatch tool with source
Output:
src/shared/gatt-server.c:276:25: warning: Variable length array is used.src/shared/gatt-server.c:619:25: warning: Variable length array is used.src/shared/gatt-server.c:718:25: warning: Variable length array is used.src/shared/gatt-server.c:276:25: warning: Variable length array is used.src/shared/gatt-server.c:619:25: warning: Variable length array is used.src/shared/gatt-server.c:718:25: warning: Variable length array is used.src/shared/gatt-server.c:276:25: warning: Variable length array is used.src/shared/gatt-server.c:619:25: warning: Variable length array is used.src/shared/gatt-server.c:718:25: warning: Variable length array is used.
---
Regards,
Linux Bluetooth