]> git.ipfire.org Git - thirdparty/systemd.git/commit
basic/socket-util: use c-escaping to print unprintable socket paths 11004/head
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 30 Nov 2018 10:54:42 +0000 (11:54 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 30 Nov 2018 20:58:47 +0000 (21:58 +0100)
commit15dca3711da63ac5fcfa01187a3b964d7042b99c
treecfa17baae1d3ff6d88e9b936ed67181536fdc9bb
parent3a484991535187a1a301eb5df2053a88bc87e2fa
basic/socket-util: use c-escaping to print unprintable socket paths

We are pretty careful to reject abstract sockets that are too long to fit in
the address structure as a NUL-terminated string. And since we parse sockets as
strings, it is not possible to embed a NUL in the the address either.  But we
might receive an external socket (abstract or not), and we want to be able to
print its address in all cases. We would call socket_address_verify() and
refuse to print various sockets that the kernel considers legit.

Let's do the strict verification only in case of socket addresses we parse and
open ourselves, and do less strict verification when printing addresses of
existing sockets, and use c-escaping to print embedded NULs and such.

More tests are added.

This should make LGTM happier because on FIXME comment is removed.
src/basic/socket-label.c
src/basic/socket-util.c
src/basic/socket-util.h
src/test/test-socket-util.c