unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Maxime Devos <maximedevos@telenet.be>
To: Leo Prikler <leo.priker@student.tugraz.at>, guile-devel@gnu.org
Subject: Re: [PATCH] Allow null bytes in UNIX sockets.
Date: Mon, 29 Mar 2021 21:26:19 +0200	[thread overview]
Message-ID: <35f6804a798b3f831b1818f8b1614584060e92bf.camel@telenet.be> (raw)
In-Reply-To: <20210329153757.16476-1-leo.priker@student.tugraz.at>

[-- Attachment #1: Type: text/plain, Size: 1684 bytes --]

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.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

  reply	other threads:[~2021-03-29 19:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-29 15:37 [PATCH] Allow null bytes in UNIX sockets Leo Prikler
2021-03-29 19:26 ` Maxime Devos [this message]
2021-05-15 16:30   ` Leo Prikler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=35f6804a798b3f831b1818f8b1614584060e92bf.camel@telenet.be \
    --to=maximedevos@telenet.be \
    --cc=guile-devel@gnu.org \
    --cc=leo.priker@student.tugraz.at \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).