[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Allow null bytes in UNIX sockets.
From: |
Maxime Devos |
Subject: |
Re: [PATCH] Allow null bytes in UNIX sockets. |
Date: |
Mon, 29 Mar 2021 21:26:19 +0200 |
User-agent: |
Evolution 3.34.2 |
On Mon, 2021-03-29 at 17:37 +0200, Leo Prikler wrote:
> The current socket address constructors all assume, that there are no
> null bytes in the socket path. This assumption does not hold in Linux,
> which uses an initial null byte to demarcate abstract sockets and
> ignores all further null bytes [1].
>
> [1] https://www.man7.org/linux/man-pages/man7/unix.7.html
>
This is necessary to connect to dbus (I forgot the proper capitalisation)
in some set-ups. I tried implementing this at some point, but Guile
crashed and I gave up.
Thank you for looking into this! One comment below.
> [...]
> diff --git a/test-suite/tests/00-socket.test b/test-suite/tests/00-socket.test
> index 027bd8519..5196b4b7d 100644
> --- a/test-suite/tests/00-socket.test
> +++ b/test-suite/tests/00-socket.test
> @@ -128,10 +128,15 @@
> (= (sockaddr:flowinfo sa*) 1)))))
>
> (if (defined? 'AF_UNIX)
> - (pass-if "AF_UNIX"
> - (let ((sa (make-socket-address AF_UNIX "/tmp/unix-socket")))
> - (and (= (sockaddr:fam sa) AF_UNIX)
> - (string=? (sockaddr:path sa) "/tmp/unix-socket"))))))
> + (begin
> + (pass-if "AF_UNIX"
> + (let ((sa (make-socket-address AF_UNIX "/tmp/unix-socket")))
> + (and (= (sockaddr:fam sa) AF_UNIX)
> + (string=? (sockaddr:path sa) "/tmp/unix-socket"))))
> + (pass-if "AF_UNIX abstract"
> + (let ((sa (make-socket-address AF_UNIX
> "\x00/tmp/abstract-socket")))
> + (and (= (sockaddr:fam sa) AF_UNIX)
> + (string=? (sockaddr:path sa) "\x00/tmp/abstract-socket")))))))
Shouldn't this code use $TMPDIR or some variable like that?
Greetings,
Maxime.
signature.asc
Description: This is a digitally signed message part