Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH v2: socket: unmetafy the socket name



Argh, forgot that metafy changes the string in place, so the one error
message where I purposely left args[0] "instead of" using the
unmetafied sockname still output garbage. Just re-metafy it here since
it's in the error path, rather than always dup the original metafied
string just in case this error needs it.

On Fri, Aug 28, 2026 at 5:14 AM Mikael Magnusson <mikachu@xxxxxxxxx> wrote:

> @@ -103,11 +106,12 @@ bin_zsocket(char *nam, char **args, Options ops, UNUSED(int func))
>         }
>
>         soun.sun_family = AF_UNIX;
> -       strncpy(soun.sun_path, localfn, sizeof(soun.sun_path)-1);
> +       memcpy(soun.sun_path, sockname, socknamelen);
> +       addrlen = offsetof(struct sockaddr_un, sun_path) + socknamelen;
>
> -       if (bind(sfd, (struct sockaddr *)&soun, sizeof(struct sockaddr_un)))
> +       if (bind(sfd, (struct sockaddr *)&soun, addrlen))
>         {
> -           zwarnnam(nam, "could not bind to %s: %e", soun.sun_path, errno);
> +           zwarnnam(nam, "could not bind to %s: %e", args[0], errno);
>             close(sfd);
>             return 1;
>         }

diff --git i/Src/Modules/socket.c w/Src/Modules/socket.c
index 4d32ee85a8..9a415e2d12 100644
--- i/Src/Modules/socket.c
+++ w/Src/Modules/socket.c
@@ -111,7 +111,7 @@ bin_zsocket(char *nam, char **args, Options ops,
UNUSED(int func))

        if (bind(sfd, (struct sockaddr *)&soun, addrlen))
        {
-           zwarnnam(nam, "could not bind to %s: %e", args[0], errno);
+           zwarnnam(nam, "could not bind to %s: %e", metafy(sockname,
socknamelen, META_STATIC), errno);
            close(sfd);
            return 1;
        }

(I'm not resending the full patch for this)

-- 
Mikael Magnusson




Messages sorted by: Reverse Date, Date, Thread, Author