Skip to contentSkip to conversation

Fix strict strncpy compiler warnings when building in BlueZ

PATCH In review Brian Gix 2 participants 4 messages Dec 7, 2018

lore
Share & tools
lore

Brian Gix

author
#0 lore raw

cover Fix strict strncpy compiler warnings when building in BlueZ

Fixes two new strict compiler warnings in bluez for strncpy

Brian Gix (2):
dbus: fix strict compiler warnings for strncpy
log: Fix strict compiler warning for strncpy

 ell/dbus.c | 4 ++--
 ell/log.c  | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
Signature · 1 line
2.17.2
author
#1 lore raw

PATCH 1/2 dbus: fix strict compiler warnings for strncpy

---
 ell/dbus.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
ell/dbus.c +2 -2
index 55aee0e..5664f85 100644
@@ -1128,7 +1128,7 @@ static struct l_dbus *setup_unix(char *params)
 		}
 
 		addr.sun_path[0] = '\0';
-		strncpy(addr.sun_path + 1, path, len);
+		strncpy(addr.sun_path + 1, path, sizeof(addr.sun_path) - 2);
 		len++;
 	} else {
 		if (len > sizeof(addr.sun_path)) {
@@ -1136,7 +1136,7 @@ static struct l_dbus *setup_unix(char *params)
 			return NULL;
 		}
 
-		strncpy(addr.sun_path, path, len);
+		strncpy(addr.sun_path, path, sizeof(addr.sun_path) - 1);
 	}
 
 	if (connect(fd, (struct sockaddr *) &addr,
Signature · 1 line
2.17.2
author
#2 lore raw

PATCH 2/2 log: Fix strict compiler warning for strncpy

In reply to Brian Gix
---
 ell/log.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
ell/log.c +1 -1
index bc1be9f..f3f4b0c 100644
@@ -86,7 +86,7 @@ static int open_log(const char *path)
 
 	memset(&addr, 0, sizeof(addr));
 	addr.sun_family = AF_UNIX;
-	strncpy(addr.sun_path, path, sizeof(addr.sun_path));
+	strncpy(addr.sun_path, path, sizeof(addr.sun_path) - 1);
 
 	if (connect(log_fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
 		close_log();
Signature · 1 line
2.17.2
#3 lore raw
In reply to Brian Gix

Hi Brian,

Quoted 9 lines

Fixes two new strict compiler warnings in bluez for strncpy

Brian Gix (2):
dbus: fix strict compiler warnings for strncpy
log: Fix strict compiler warning for strncpy

ell/dbus.c | 4 ++--
ell/log.c | 2 +-

2 files changed, 3 insertions(+), 3 deletions(-)

both patches have been applied.

Regards

Marcel