From 40ba8a3d347ef83669710378830bc49b809b755f Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Fri, 11 Jul 2014 10:38:24 +0300 Subject: [PATCH] profiles/input: Fix usage of PATH_MAX PATH_MAX already contains the terminating null so there's no need to +1 to it. Also, snprintf guarantees a null-terminated string so there's no need to explicitly set a terminating character after the call. --- profiles/input/device.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/profiles/input/device.c b/profiles/input/device.c index a61b2c7e4..6b5a29046 100644 --- a/profiles/input/device.c +++ b/profiles/input/device.c @@ -918,7 +918,7 @@ static int hidp_add_connection(struct input_device *idev) struct hidp_connadd_req *req; sdp_record_t *rec; char src_addr[18], dst_addr[18]; - char filename[PATH_MAX + 1]; + char filename[PATH_MAX]; GKeyFile *key_file; char handle[11], *str; GError *gerr = NULL; @@ -935,7 +935,6 @@ static int hidp_add_connection(struct input_device *idev) snprintf(filename, PATH_MAX, STORAGEDIR "/%s/cache/%s", src_addr, dst_addr); - filename[PATH_MAX] = '\0'; sprintf(handle, "0x%8.8X", idev->handle); key_file = g_key_file_new(); -- 2.47.3