]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
compress: limit the output to dst_max bytes with LZ4 if set
authorFrantisek Sumsal <frantisek@sumsal.cz>
Sun, 12 Apr 2026 14:24:53 +0000 (16:24 +0200)
committerFrantisek Sumsal <frantisek@sumsal.cz>
Sun, 12 Apr 2026 14:28:15 +0000 (16:28 +0200)
We already do that with other algorithms, so let's make
decompress_blob_lz4() consistent with the rest.

src/basic/compress.c

index 251eb02fbb75a7ad457a42729a5120c93c8f006a..b2a42f44e94c5b9f6d6ca610d21c94b1ec4bfc2e 100644 (file)
@@ -739,6 +739,8 @@ static int decompress_blob_lz4(
         size = unaligned_read_le64(src);
         if (size < 0 || (unsigned) size != unaligned_read_le64(src))
                 return -EFBIG;
+        if (dst_max > 0 && (size_t) size > dst_max)
+                return -ENOBUFS;
         out = greedy_realloc(dst, size, 1);
         if (!out)
                 return -ENOMEM;