From 226815dbd88536b6d97497b897c314a0e7d6e941 Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Tue, 5 Jan 2021 03:26:57 +0700 Subject: [PATCH] Pass correct sockaddr size to bind. (#178) We should be passing the size of the `struct sockaddr_un`, not the length of the path + the size of the path field. There is another `bind` call in this file that had it right. --- src/unixcomm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unixcomm.c b/src/unixcomm.c index b7e84fa..ea02471 100644 --- a/src/unixcomm.c +++ b/src/unixcomm.c @@ -793,7 +793,7 @@ LispPTR Unix_handlecomm(LispPTR *args) { sock.sun_family = AF_UNIX; strcpy(sock.sun_path, shcom); - if (bind(sockFD, (struct sockaddr *)&sock, strlen(shcom) + sizeof(sock.sun_family)) < 0) { + if (bind(sockFD, (struct sockaddr *)&sock, sizeof(struct sockaddr_un)) < 0) { close(sockFD); free(UJ[sockFD].pathname); UJ[sockFD].type = UJUNUSED;