]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-journal: skip full decompression when caller only checks field existence
authornoxiouz <atiurin@proton.me>
Tue, 7 Apr 2026 15:29:56 +0000 (16:29 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@amutable.com>
Wed, 8 Apr 2026 14:33:20 +0000 (16:33 +0200)
When both ret_data and ret_size are NULL after decompress_startswith()
has confirmed the field matches, skip the decompress_blob() call.
This avoids decompressing potentially large payloads (e.g. inline
coredumps) just to discard the result.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
src/libsystemd/sd-journal/journal-file.c

index 363df258a17709fb3a3dbe4e5f06a7f8a932e01a..235f4712245047de1189df0666b938f0d5a78157 100644 (file)
@@ -1965,6 +1965,10 @@ static int maybe_decompress_payload(
                                         *ret_size = 0;
                                 return 0;
                         }
+
+                        /* Caller only wants to check field existence, skip full decompression */
+                        if (!ret_data && !ret_size)
+                                return 1;
                 }
 
                 r = decompress_blob(compression, payload, size, &f->compress_buffer, &rsize, 0);