From ee82dda599b31a96a3e438e458b67a230ed73866 Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Sat, 26 Apr 2014 15:03:26 +0200 Subject: [PATCH] shared/gatt: Fix undefined behaviour in memcpy Check len before copying data. --- src/shared/gatt-db.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c index 20fb63176..db1fdffe9 100644 --- a/src/shared/gatt-db.c +++ b/src/shared/gatt-db.c @@ -117,8 +117,9 @@ static struct gatt_db_attribute *new_attribute(const bt_uuid_t *type, return NULL; attribute->uuid = *type; - memcpy(&attribute->value, val, len); attribute->val_len = len; + if (len) + memcpy(&attribute->value, val, len); return attribute; } -- 2.47.3