From 7f13044df170476dd124908ba1bef32c636cd7c8 Mon Sep 17 00:00:00 2001 From: Iulia Tanasescu Date: Tue, 13 Jun 2023 17:16:24 +0300 Subject: [PATCH] gatt-server: Check pointer before memcpy 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 c885c74..6a8380c 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 * * */ @@ -1952,7 +1953,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.7.4