]> git.ipfire.org Git - people/stevee/ipfire-3.x.git/blame - systemd/patches/0003-bus-socket-Fix-line_begins-to-accept-word-matching-f.patch
kmod: Update to 26
[people/stevee/ipfire-3.x.git] / systemd / patches / 0003-bus-socket-Fix-line_begins-to-accept-word-matching-f.patch
CommitLineData
aaa616e7
SS
1From 3f10c66270b74530339b3f466c43874bb40c210f Mon Sep 17 00:00:00 2001
2From: Filipe Brandenburger <filbranden@google.com>
3Date: Tue, 17 Jul 2018 11:32:40 -0700
4Subject: [PATCH] bus-socket: Fix line_begins() to accept word matching full
5 string
6
7The switch to memory_startswith() changed the logic to only look for a space or
8NUL byte after the matched word, but matching the full size should also be
9acceptable.
10
11This changed the behavior of parsing of "AUTH\r\n", where m will be set to 4,
12since even though the word will match, the check for it being followed by ' '
13or NUL will make line_begins() return false.
14
15Tested:
16
17- Using netcat to connect to the private socket directly:
18 $ echo -ne '\0AUTH\r\n' | sudo nc -U /run/systemd/private
19 REJECTED EXTERNAL ANONYMOUS
20
21- Running the Ignition blackbox test:
22 $ sudo sh -c 'PATH=$PWD/bin/amd64:$PATH ./tests.test'
23 PASS
24
25Fixes: d27b725abf64a19a6b2f99332b663f17ad046771
26---
27 src/libsystemd/sd-bus/bus-socket.c | 5 +----
28 1 file changed, 1 insertion(+), 4 deletions(-)
29
30diff --git a/src/libsystemd/sd-bus/bus-socket.c b/src/libsystemd/sd-bus/bus-socket.c
31index be491c957..a785a247c 100644
32--- a/src/libsystemd/sd-bus/bus-socket.c
33+++ b/src/libsystemd/sd-bus/bus-socket.c
34@@ -246,10 +246,7 @@ static bool line_begins(const char *s, size_t m, const char *word) {
35 const char *p;
36
37 p = memory_startswith(s, m, word);
38- if (!p)
39- return false;
40-
41- return IN_SET(*p, 0, ' ');
42+ return p && (p == (s + m) || *p == ' ');
43 }
44
45 static int verify_anonymous_token(sd_bus *b, const char *p, size_t l) {
46--
472.14.4
48