|
Jan Synacek |
d8d2ff |
From 3f10c66270b74530339b3f466c43874bb40c210f Mon Sep 17 00:00:00 2001
|
|
Jan Synacek |
d8d2ff |
From: Filipe Brandenburger <filbranden@google.com>
|
|
Jan Synacek |
d8d2ff |
Date: Tue, 17 Jul 2018 11:32:40 -0700
|
|
Jan Synacek |
d8d2ff |
Subject: [PATCH] bus-socket: Fix line_begins() to accept word matching full
|
|
Jan Synacek |
d8d2ff |
string
|
|
Jan Synacek |
d8d2ff |
|
|
Jan Synacek |
d8d2ff |
The switch to memory_startswith() changed the logic to only look for a space or
|
|
Jan Synacek |
d8d2ff |
NUL byte after the matched word, but matching the full size should also be
|
|
Jan Synacek |
d8d2ff |
acceptable.
|
|
Jan Synacek |
d8d2ff |
|
|
Jan Synacek |
d8d2ff |
This changed the behavior of parsing of "AUTH\r\n", where m will be set to 4,
|
|
Jan Synacek |
d8d2ff |
since even though the word will match, the check for it being followed by ' '
|
|
Jan Synacek |
d8d2ff |
or NUL will make line_begins() return false.
|
|
Jan Synacek |
d8d2ff |
|
|
Jan Synacek |
d8d2ff |
Tested:
|
|
Jan Synacek |
d8d2ff |
|
|
Jan Synacek |
d8d2ff |
- Using netcat to connect to the private socket directly:
|
|
Jan Synacek |
d8d2ff |
$ echo -ne '\0AUTH\r\n' | sudo nc -U /run/systemd/private
|
|
Jan Synacek |
d8d2ff |
REJECTED EXTERNAL ANONYMOUS
|
|
Jan Synacek |
d8d2ff |
|
|
Jan Synacek |
d8d2ff |
- Running the Ignition blackbox test:
|
|
Jan Synacek |
d8d2ff |
$ sudo sh -c 'PATH=$PWD/bin/amd64:$PATH ./tests.test'
|
|
Jan Synacek |
d8d2ff |
PASS
|
|
Jan Synacek |
d8d2ff |
|
|
Jan Synacek |
d8d2ff |
Fixes: d27b725abf64a19a6b2f99332b663f17ad046771
|
|
Jan Synacek |
d8d2ff |
---
|
|
Jan Synacek |
d8d2ff |
src/libsystemd/sd-bus/bus-socket.c | 5 +----
|
|
Jan Synacek |
d8d2ff |
1 file changed, 1 insertion(+), 4 deletions(-)
|
|
Jan Synacek |
d8d2ff |
|
|
Jan Synacek |
d8d2ff |
diff --git a/src/libsystemd/sd-bus/bus-socket.c b/src/libsystemd/sd-bus/bus-socket.c
|
|
Jan Synacek |
d8d2ff |
index be491c957..a785a247c 100644
|
|
Jan Synacek |
d8d2ff |
--- a/src/libsystemd/sd-bus/bus-socket.c
|
|
Jan Synacek |
d8d2ff |
+++ b/src/libsystemd/sd-bus/bus-socket.c
|
|
Jan Synacek |
d8d2ff |
@@ -246,10 +246,7 @@ static bool line_begins(const char *s, size_t m, const char *word) {
|
|
Jan Synacek |
d8d2ff |
const char *p;
|
|
Jan Synacek |
d8d2ff |
|
|
Jan Synacek |
d8d2ff |
p = memory_startswith(s, m, word);
|
|
Jan Synacek |
d8d2ff |
- if (!p)
|
|
Jan Synacek |
d8d2ff |
- return false;
|
|
Jan Synacek |
d8d2ff |
-
|
|
Jan Synacek |
d8d2ff |
- return IN_SET(*p, 0, ' ');
|
|
Jan Synacek |
d8d2ff |
+ return p && (p == (s + m) || *p == ' ');
|
|
Jan Synacek |
d8d2ff |
}
|
|
Jan Synacek |
d8d2ff |
|
|
Jan Synacek |
d8d2ff |
static int verify_anonymous_token(sd_bus *b, const char *p, size_t l) {
|
|
Jan Synacek |
d8d2ff |
--
|
|
Jan Synacek |
d8d2ff |
2.14.4
|
|
Jan Synacek |
d8d2ff |
|