Skip to content
Browse files

bus-socket: Fix line_begins() to accept word matching full string

The switch to memory_startswith() changed the logic to only look for a space or
NUL byte after the matched word, but matching the full size should also be

This changed the behavior of parsing of "AUTH\r\n", where m will be set to 4,
since even though the word will match, the check for it being followed by ' '
or NUL will make line_begins() return false.


- Using netcat to connect to the private socket directly:
  $ echo -ne '\0AUTH\r\n' | sudo nc -U /run/systemd/private

- Running the Ignition blackbox test:
  $ sudo sh -c 'PATH=$PWD/bin/amd64:$PATH ./tests.test'

Fixes: d27b725
  • Loading branch information...
filbranden authored and poettering committed Jul 17, 2018
1 parent ed698d3 commit 3f10c66270b74530339b3f466c43874bb40c210f
Showing with 1 addition and 4 deletions.
  1. +1 −4 src/libsystemd/sd-bus/bus-socket.c
@@ -246,10 +246,7 @@ static bool line_begins(const char *s, size_t m, const char *word) {
const char *p;

p = memory_startswith(s, m, word);
if (!p)
return false;

return IN_SET(*p, 0, ' ');
return p && (p == (s + m) || *p == ' ');

static int verify_anonymous_token(sd_bus *b, const char *p, size_t l) {

0 comments on commit 3f10c66

Please sign in to comment.
You can’t perform that action at this time.