diff options
author | Filipe Brandenburger <filbranden@google.com> | 2018-07-17 11:32:40 -0700 |
---|---|---|
committer | Sven Eden <sven.eden@prydeworx.com> | 2018-10-29 10:18:23 +0100 |
commit | 8cb18f4e713a571123c1c4bf65f4eb7e50096be2 (patch) | |
tree | e75c29d1a413ec570bcc01648541fda8e5ab79c9 /src | |
parent | 859da64a725c25b518e975dfcb9049ce60ac068e (diff) |
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
acceptable.
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.
Tested:
- Using netcat to connect to the private socket directly:
$ echo -ne '\0AUTH\r\n' | sudo nc -U /run/systemd/private
REJECTED EXTERNAL ANONYMOUS
- Running the Ignition blackbox test:
$ sudo sh -c 'PATH=$PWD/bin/amd64:$PATH ./tests.test'
PASS
Fixes: d27b725abf64a19a6b2f99332b663f17ad046771
(cherry picked from commit 3f10c66270b74530339b3f466c43874bb40c210f)
Diffstat (limited to 'src')
-rw-r--r-- | src/libelogind/sd-bus/bus-socket.c | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/src/libelogind/sd-bus/bus-socket.c b/src/libelogind/sd-bus/bus-socket.c index b147a3843..a5513d1ab 100644 --- a/src/libelogind/sd-bus/bus-socket.c +++ b/src/libelogind/sd-bus/bus-socket.c @@ -248,10 +248,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) { |