diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2015-03-13 21:11:03 -0500 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2015-03-13 23:42:17 -0400 |
commit | 39d0fd9c0cb9a39779d3466bd22a5fe6b3ed9fa5 (patch) | |
tree | 0b85334e2ff2d8f50e9999ec0d000bb83e155eaa /src/journal-remote | |
parent | 012d7b4217420163db5752a63da6cab39d25edf3 (diff) |
journal-remote: explain why source->buf cannot be null
In reference to CID #1238956.
Diffstat (limited to 'src/journal-remote')
-rw-r--r-- | src/journal-remote/journal-remote-parse.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/journal-remote/journal-remote-parse.c b/src/journal-remote/journal-remote-parse.c index 65ef7668f1..e8442d319e 100644 --- a/src/journal-remote/journal-remote-parse.c +++ b/src/journal-remote/journal-remote-parse.c @@ -114,19 +114,24 @@ static int get_line(RemoteSource *source, char **line, size_t *size) { /* we have to wait for some data to come to us */ return -EAGAIN; + /* We know that source->filled is at most DATA_SIZE_MAX, so if + we reallocate it, we'll increase the size at least a bit. */ + assert_cc(DATA_SIZE_MAX < ENTRY_SIZE_MAX); if (source->size - source->filled < LINE_CHUNK && - !realloc_buffer(source, - MIN(source->filled + LINE_CHUNK, ENTRY_SIZE_MAX))) + !realloc_buffer(source, MIN(source->filled + LINE_CHUNK, ENTRY_SIZE_MAX))) return log_oom(); + assert(source->buf); assert(source->size - source->filled >= LINE_CHUNK || source->size == ENTRY_SIZE_MAX); - n = read(source->fd, source->buf + source->filled, + n = read(source->fd, + source->buf + source->filled, source->size - source->filled); if (n < 0) { if (errno != EAGAIN) - log_error_errno(errno, "read(%d, ..., %zu): %m", source->fd, + log_error_errno(errno, "read(%d, ..., %zu): %m", + source->fd, source->size - source->filled); return -errno; } else if (n == 0) |