tunnel: download hash list in chunks if necessary

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld 2021-05-07 10:22:41 +02:00
parent 94ecb13d2f
commit 6acc1125b8

View File

@ -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");