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