From: Zbigniew Jędrzejewski-Szmek Date: Thu, 10 Dec 2015 14:38:50 +0000 (-0500) Subject: journal: decompress_startswith can return an error X-Git-Tag: v229~195^2~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2aaec9b4f61c1c1fa3374f40f0f1e828b6c53e1e;p=thirdparty%2Fsystemd.git journal: decompress_startswith can return an error The return value was used directly in an if, so an error was treated as success; we need to bail out instead. An error should not happen, unless we have a compression/decompression mismatch, so output a debug line. --- diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c index 5cde7f17f7d..cd5160154ad 100644 --- a/src/journal/sd-journal.c +++ b/src/journal/sd-journal.c @@ -1940,10 +1940,14 @@ _public_ int sd_journal_get_data(sd_journal *j, const char *field, const void ** compression = o->object.flags & OBJECT_COMPRESSION_MASK; if (compression) { #if defined(HAVE_XZ) || defined(HAVE_LZ4) - if (decompress_startswith(compression, + r = decompress_startswith(compression, o->data.payload, l, &f->compress_buffer, &f->compress_buffer_size, - field, field_length, '=')) { + field, field_length, '='); + if (r < 0) + log_debug_errno(r, "Cannot decompress %s object of length %zu at offset "OFSfmt": %m", + object_compressed_to_string(compression), l, p); + else if (r > 0) { size_t rsize;