Diff between a06299a279efcb3f48ad0760a15f75d1d9ac87e2 and 1ba6ec3fbc7be27d5401b7e38d5dd3d399e1ae2e

Changed Files

File Additions Deletions Status
src/attrib-server.c +14 -2 modified

Full Patch

diff --git a/src/attrib-server.c b/src/attrib-server.c
index 81697ce..61bc01d 100644
--- a/src/attrib-server.c
+++ b/src/attrib-server.c
@@ -757,6 +757,10 @@ static int read_device_ccc(struct btd_device *device, uint16_t handle,
 	int err = 0;
 
 	filename = btd_device_get_storage_path(device, "ccc");
+	if (!filename) {
+		warn("Unable to get ccc storage path for device");
+		return -ENOENT;
+	}
 
 	key_file = g_key_file_new();
 	g_key_file_load_from_file(key_file, filename, 0, NULL);
@@ -898,6 +902,12 @@ static uint16_t write_value(struct gatt_channel *channel, uint16_t handle,
 		gsize length = 0;
 
 		filename = btd_device_get_storage_path(channel->device, "ccc");
+		if (!filename) {
+			warn("Unable to get ccc storage path for device");
+			return enc_error_resp(ATT_OP_WRITE_REQ, handle,
+						ATT_ECODE_WRITE_NOT_PERM,
+						pdu, len);
+		}
 
 		key_file = g_key_file_new();
 		g_key_file_load_from_file(key_file, filename, 0, NULL);
@@ -1138,8 +1148,10 @@ guint attrib_channel_attach(GAttrib *attrib)
 		char *filename;
 
 		filename = btd_device_get_storage_path(device, "ccc");
-		unlink(filename);
-		g_free(filename);
+		if (filename) {
+			unlink(filename);
+			g_free(filename);
+		}
 	}
 
 	if (cid != ATT_CID) {