From: Klearchos Chaloulos Date: Fri, 22 Apr 2016 18:04:17 +0000 (+0300) Subject: journal-remote : Ensure reallocation of source->buf does not result in source->size... X-Git-Tag: v230~149 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9ba37525d0ef3d144a50ed5fd4710573e92b7ec1;p=thirdparty%2Fsystemd.git journal-remote : Ensure reallocation of source->buf does not result in source->size < source->filled (#3086) While the function journal-remote-parse.c:get_line() enforces an assertion that source->filled <= source->size, in function journal-remote-parse.c:process_source() there is a chance that source->size will be decreased to a lower value than source->filled, when source->buf is reallocated. Therefore a check is added that ensures that source->buf is reallocated only when source->filled is smaller than target / 2. --- diff --git a/src/journal-remote/journal-remote-parse.c b/src/journal-remote/journal-remote-parse.c index 3864647eb70..9ba9ee3fc04 100644 --- a/src/journal-remote/journal-remote-parse.c +++ b/src/journal-remote/journal-remote-parse.c @@ -485,7 +485,7 @@ int process_source(RemoteSource *source, bool compress, bool seal) { } target = source->size; - while (target > 16 * LINE_CHUNK && remain < target / 2) + while (target > 16 * LINE_CHUNK && source->filled < target / 2) target /= 2; if (target < source->size) { char *tmp;