From 6acc1125b88e3ab9274b15722a0728a66bb3f16b Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Fri, 7 May 2021 10:22:41 +0200 Subject: tunnel: download hash list in chunks if necessary Signed-off-by: Jason A. Donenfeld --- tunnel/src/main/java/com/wireguard/android/util/ModuleLoader.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'tunnel/src/main/java/com') diff --git a/tunnel/src/main/java/com/wireguard/android/util/ModuleLoader.java b/tunnel/src/main/java/com/wireguard/android/util/ModuleLoader.java index e6605057..d1ad9e16 100644 --- a/tunnel/src/main/java/com/wireguard/android/util/ModuleLoader.java +++ b/tunnel/src/main/java/com/wireguard/android/util/ModuleLoader.java @@ -94,7 +94,11 @@ public class ModuleLoader { final byte[] input = new byte[1024 * 1024 * 3 /* 3MiB */]; int len; try (final InputStream inputStream = connection.getInputStream()) { - len = inputStream.read(input); + int offset = 0; + while (input.length - offset > 0 && (len = inputStream.read(input, offset, input.length - offset)) > 0) { + offset += len; + } + len = offset; } if (len <= 0) throw new IOException("Hash list was empty"); -- cgit v1.2.3