]>
Commit | Line | Data |
---|---|---|
aaa616e7 SS |
1 | From 3f10c66270b74530339b3f466c43874bb40c210f Mon Sep 17 00:00:00 2001 |
2 | From: Filipe Brandenburger <filbranden@google.com> | |
3 | Date: Tue, 17 Jul 2018 11:32:40 -0700 | |
4 | Subject: [PATCH] bus-socket: Fix line_begins() to accept word matching full | |
5 | string | |
6 | ||
7 | The switch to memory_startswith() changed the logic to only look for a space or | |
8 | NUL byte after the matched word, but matching the full size should also be | |
9 | acceptable. | |
10 | ||
11 | This changed the behavior of parsing of "AUTH\r\n", where m will be set to 4, | |
12 | since even though the word will match, the check for it being followed by ' ' | |
13 | or NUL will make line_begins() return false. | |
14 | ||
15 | Tested: | |
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 | ||
25 | Fixes: d27b725abf64a19a6b2f99332b663f17ad046771 | |
26 | --- | |
27 | src/libsystemd/sd-bus/bus-socket.c | 5 +---- | |
28 | 1 file changed, 1 insertion(+), 4 deletions(-) | |
29 | ||
30 | diff --git a/src/libsystemd/sd-bus/bus-socket.c b/src/libsystemd/sd-bus/bus-socket.c | |
31 | index 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 | -- | |
47 | 2.14.4 | |
48 |