summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--Src/Modules/socket.c11
2 files changed, 13 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 876e5f0ab..4d6130ba9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -20,6 +20,9 @@
* 54492: Src/Zle/termquery.c: is* classification functions take
unsigned char
+ * 54493: Src/Modules/socket.c: socket: fix some issues with
+ socket name
+
2026-05-10 Oliver Kiddle <opk@zsh.org>
* unposted: Completion/Linux/Command/_selinux: complete files
diff --git a/Src/Modules/socket.c b/Src/Modules/socket.c
index c65b7dfce..4f2a6ecbf 100644
--- a/Src/Modules/socket.c
+++ b/Src/Modules/socket.c
@@ -58,7 +58,7 @@ bin_zsocket(char *nam, char **args, Options ops, UNUSED(int func))
{
int err=1, verbose=0, test=0, targetfd=0;
ZSOCKLEN_T len;
- struct sockaddr_un soun;
+ struct sockaddr_un soun = { 0 };
int sfd;
if (OPT_ISSET(ops,'v'))
@@ -90,6 +90,10 @@ bin_zsocket(char *nam, char **args, Options ops, UNUSED(int func))
}
localfn = args[0];
+ if (strlen(localfn) >= sizeof(soun.sun_path)) {
+ zwarnnam(nam, "socket path too long: %d > %d", strlen(localfn), sizeof(soun.sun_path) -1 );
+ return 1;
+ }
sfd = socket(PF_UNIX, SOCK_STREAM, 0);
@@ -232,6 +236,11 @@ bin_zsocket(char *nam, char **args, Options ops, UNUSED(int func))
return 1;
}
+ if (strlen(args[0]) >= sizeof(soun.sun_path)) {
+ zwarnnam(nam, "socket path too long: %d > %d", strlen(args[0]), sizeof(soun.sun_path) -1 );
+ return 1;
+ }
+
sfd = socket(PF_UNIX, SOCK_STREAM, 0);
if (sfd == -1) {