]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journal-gatewayd: fix segfault with certain request (#3893)
authorYi EungJun <semtlenori@gmail.com>
Sat, 6 Aug 2016 20:39:13 +0000 (05:39 +0900)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 6 Aug 2016 20:39:13 +0000 (16:39 -0400)
When client requests to get logs with `follow` and `KEY=match` that
doesn't match any log entry, journal-gatewayd segfaulted.

Make request_reader_entries to return zero in such case to wait for
matching entries.

This fixes https://github.com/systemd/systemd/issues/3873.

src/journal-remote/journal-gatewayd.c

index 4d785c819f7104910110857af933f61d47ab2149..05c8698f78d92ea180663e6da431a12f25cf5277 100644 (file)
@@ -240,6 +240,9 @@ static ssize_t request_reader_entries(
                 m->size = (uint64_t) sz;
         }
 
+        if (m->tmp == NULL && m->follow)
+                return 0;
+
         if (fseeko(m->tmp, pos, SEEK_SET) < 0) {
                 log_error_errno(errno, "Failed to seek to position: %m");
                 return MHD_CONTENT_READER_END_WITH_ERROR;