From 74e54f8d20e63d8796b01e8b89d005eac00fc481 Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 11 Mar 2022 15:58:18 +0100 Subject: [PATCH] Hard limit uncompressed output --- app/src/main/java/eu/faircode/email/MessageHelper.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/src/main/java/eu/faircode/email/MessageHelper.java b/app/src/main/java/eu/faircode/email/MessageHelper.java index 2e3e122767..908da9ed9a 100644 --- a/app/src/main/java/eu/faircode/email/MessageHelper.java +++ b/app/src/main/java/eu/faircode/email/MessageHelper.java @@ -3421,6 +3421,8 @@ public class MessageHelper { byte[] buffer = new byte[Helper.BUFFER_SIZE]; for (int len = gzip.read(buffer); len != -1; len = gzip.read(buffer)) { size += len; + if (size > MAX_UNZIP_SIZE) + throw new IOException("File too large"); os.write(buffer, 0, len); if (total > 0) { @@ -3503,6 +3505,8 @@ public class MessageHelper { byte[] buffer = new byte[Helper.BUFFER_SIZE]; for (int len = ais.read(buffer); len != -1; len = ais.read(buffer)) { size += len; + if (size > MAX_UNZIP_SIZE) + throw new IOException("File too large"); os.write(buffer, 0, len); if (total > 0) {