luad

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 262fc6437c1f1ca2c1bb08da00d9ff8b5ed54efd
parent 9569ba3cfa0614ffd9921de81144604e5f343ccb
Author: Daniel Barlow <dan@telent.net>
Date:   Mon, 18 May 2026 23:26:48 +0100

die with sensible error message if socket path too long

Diffstat:
Mluad.c | 6+++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/luad.c b/luad.c @@ -32,7 +32,11 @@ static void handle_sigchld(int num) { int open_socket(char * pathname) { struct sockaddr_un addr; addr.sun_family = AF_UNIX; - strncpy(addr.sun_path, pathname, sizeof(addr.sun_path) - 1); + if(strlen(pathname) > sizeof(addr.sun_path)) { + die("pathname \"%s\" is too long to bind as unix socket (max %lu)", + pathname, sizeof(addr.sun_path)); + } + strcpy(addr.sun_path, pathname); int fd = socket(AF_LOCAL, SOCK_DGRAM, PF_LOCAL); if(fd < 0) {