aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2021-05-07 10:22:41 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2021-05-07 10:25:10 +0200
commit6acc1125b88e3ab9274b15722a0728a66bb3f16b (patch)
treedd6d21d3a7e5bc00ae83a59e56ee23f2ee687d82
parentui: update datastore and rework api (diff)
downloadwireguard-android-6acc1125b88e3ab9274b15722a0728a66bb3f16b.tar.xz
wireguard-android-6acc1125b88e3ab9274b15722a0728a66bb3f16b.zip
tunnel: download hash list in chunks if necessary
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r--tunnel/src/main/java/com/wireguard/android/util/ModuleLoader.java6
1 files changed, 5 insertions, 1 deletions
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 e660505..d1ad9e1 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");