summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--dispatch.c2
-rw-r--r--local.c4
2 files changed, 3 insertions, 3 deletions
diff --git a/dispatch.c b/dispatch.c
index e80f297..d762105 100644
--- a/dispatch.c
+++ b/dispatch.c
@@ -288,7 +288,7 @@ int main(int argc, char *argv[]) {
 			}
 
 			struct sockaddr_un addr = { .sun_family = AF_UNIX };
-			strncpy(addr.sun_path, name, sizeof(addr.sun_path));
+			strlcpy(addr.sun_path, name, sizeof(addr.sun_path));
 
 			int sock = socket(PF_UNIX, SOCK_STREAM, 0);
 			if (sock < 0) err(EX_OSERR, "socket");
diff --git a/local.c b/local.c
index eccd2e6..6ef452b 100644
--- a/local.c
+++ b/local.c
@@ -131,10 +131,10 @@ size_t localUnix(int fds[], size_t cap, const char *path) {
 	if (sock < 0) err(EX_OSERR, "socket");
 
 	struct sockaddr_un addr = { .sun_family = AF_UNIX };
-	if (strlen(path) > sizeof(addr.sun_path)) {
+	size_t len = strlcpy(addr.sun_path, path, sizeof(addr.sun_path));
+	if (len >= sizeof(addr.sun_path)) {
 		errx(EX_CONFIG, "path too long: %s", path);
 	}
-	strncpy(addr.sun_path, path, sizeof(addr.sun_path));
 
 	int error = bind(sock, (struct sockaddr *)&addr, SUN_LEN(&addr));
 	if (error) err(EX_UNAVAILABLE, "%s", path);
7838ecb9e4c7cd3d4&follow=1'>Clean up notemap with dataCheckJune McEnroe 2020-05-04Update IMAP parserJune McEnroe 2020-04-08Use a real IMAP parserJune McEnroe 2020-01-28Call fopencookie with a+ 1.0June McEnroe 2020-01-28Add arc4random_buf compatibilityJune McEnroe