diff mbox

[v5,1/2] Btrfs: lzo.c - compressed data size must be less then input size

Message ID 20170529231805.4797-2-nefelim4ag@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Timofey Titovets May 29, 2017, 11:18 p.m. UTC
Logic already return error if compression
make data bigger, let's sync logic with zlib
and also return error if compressed size
are equal to input size

Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
---
 fs/btrfs/lzo.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--
2.13.0
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

David Sterba June 5, 2017, 3:59 p.m. UTC | #1
On Tue, May 30, 2017 at 02:18:04AM +0300, Timofey Titovets wrote:
> Logic already return error if compression
> make data bigger, let's sync logic with zlib
> and also return error if compressed size
> are equal to input size
> 
> Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>

Reviewed-by: David Sterba <dsterba@suse.com>

I've updated the changelog a bit.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/btrfs/lzo.c b/fs/btrfs/lzo.c
index f48c8c14..f66691e0 100644
--- a/fs/btrfs/lzo.c
+++ b/fs/btrfs/lzo.c
@@ -229,8 +229,10 @@  static int lzo_compress_pages(struct list_head *ws,
 		in_len = min(bytes_left, PAGE_SIZE);
 	}

-	if (tot_out > tot_in)
+	if (tot_out >= tot_in) {
+		ret = -E2BIG;
 		goto out;
+	}

 	/* store the size of all chunks of compressed data */
 	cpage_out = kmap(pages[0]);