bus-socket: Fix line_begins() to accept word matching full string
authorFilipe Brandenburger <filbranden@google.com>
Tue, 17 Jul 2018 18:32:40 +0000 (11:32 -0700)
committerLukáš Nykrýn <lnykryn@redhat.com>
Wed, 27 Mar 2019 10:30:17 +0000 (11:30 +0100)
commit94b18b8123b5d957ed84e4aa8e268b60f5427821
tree59b2c66fd464f6faa819710b5529e0096e1d450f
parent9cf9680910544638129bf083bca902881d9ab5bc
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)

Resolves: #1692991
src/libsystemd/sd-bus/bus-socket.c