diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-10-22 15:04:54 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-10-22 15:05:22 +0200 |
commit | 16890a659e6d7877b86e870fe4f0ef9cc19aee5b (patch) | |
tree | 5299bf4f2d93131810b72560931b68a76ded868c /app | |
parent | d40ac7f89daf478f82b022bae95d65ade611c4ce (diff) |
ModuleLoader: sync file before renaming
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'app')
-rw-r--r-- | app/src/main/java/com/wireguard/android/util/ModuleLoader.java | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/app/src/main/java/com/wireguard/android/util/ModuleLoader.java b/app/src/main/java/com/wireguard/android/util/ModuleLoader.java index 524d10a6..f5bca0f2 100644 --- a/app/src/main/java/com/wireguard/android/util/ModuleLoader.java +++ b/app/src/main/java/com/wireguard/android/util/ModuleLoader.java @@ -22,7 +22,6 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; -import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.URL; import java.nio.charset.StandardCharsets; @@ -159,7 +158,7 @@ public class ModuleLoader { tempFile = File.createTempFile("UNVERIFIED-", null, tmpDir); MessageDigest digest = MessageDigest.getInstance("SHA-256"); try (final InputStream inputStream = connection.getInputStream(); - final OutputStream outputStream = new FileOutputStream(tempFile)) { + final FileOutputStream outputStream = new FileOutputStream(tempFile)) { int total = 0; while ((len = inputStream.read(input)) > 0) { total += len; @@ -168,6 +167,7 @@ public class ModuleLoader { outputStream.write(input, 0, len); digest.update(input, 0, len); } + outputStream.getFD().sync(); } if (!Arrays.equals(digest.digest(), modules.get(moduleName).bytes)) throw new IOException("Incorrect file hash"); |