]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journal: don't use startswith() on something that is not a NUL-terminated string
authorLennart Poettering <lennart@poettering.net>
Tue, 21 Jan 2020 09:49:58 +0000 (10:49 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 21 Jan 2020 13:32:15 +0000 (14:32 +0100)
Otherwise we might access memory coming after it that is not valid or
allocated.

Fixes: #14114
src/journal/sd-journal.c

index 358f2fd738ef9aa2be9f9fbc5ed002f95e46940f..837aecdf605698bc45392761806cd1e69c8cc1a8 100644 (file)
@@ -161,7 +161,7 @@ static int match_is_valid(const void *data, size_t size) {
         if (size < 2)
                 return false;
 
-        if (startswith(data, "__"))
+        if (((char*) data)[0] == '_' && ((char*) data)[1] == '_')
                 return false;
 
         b = data;