From 218d93b37b7d1917598489d0ffc8d32bf34c7c56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Pierre=20Andr=C3=A9?= Date: Mon, 17 May 2021 15:38:20 +0300 Subject: [PATCH] Cleaned the tail of compressed buffer before writing a full cluster When appending to an existing compressed file, the last block must first be decompressed. When doing so, clear the tail of buffer in order to not leak unrelated data. --- libntfs-3g/compress.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libntfs-3g/compress.c b/libntfs-3g/compress.c index fb69a0e6..0c22bc9c 100644 --- a/libntfs-3g/compress.c +++ b/libntfs-3g/compress.c @@ -1618,7 +1618,7 @@ static int ntfs_read_append(ntfs_attr *na, const runlist_element *rl, */ static s32 ntfs_flush(ntfs_attr *na, runlist_element *rl, s64 offs, - const char *outbuf, s32 count, BOOL compress, + char *outbuf, s32 count, BOOL compress, BOOL appending, VCN *update_from) { s32 rounded; @@ -1639,6 +1639,8 @@ static s32 ntfs_flush(ntfs_attr *na, runlist_element *rl, s64 offs, if (!compress) { clsz = 1 << na->ni->vol->cluster_size_bits; rounded = ((count - 1) | (clsz - 1)) + 1; + if (rounded > count) + memset(&outbuf[count], 0, rounded - count); written = write_clusters(na->ni->vol, rl, offs, rounded, outbuf); if (written != rounded)