diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-01-08 20:41:36 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-01-08 20:42:12 +0100 |
commit | 1ae10b8f45713b92cf6082dcb00ece6c58eda225 (patch) | |
tree | 0d0e42c5785bd592947f873fe7d942a8f950841e | |
parent | 5944efc13cd3b63d3a6c38b583116cb06c22d439 (diff) |
RootShell: fix off by one
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r-- | app/src/main/java/com/wireguard/android/util/RootShell.java | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/app/src/main/java/com/wireguard/android/util/RootShell.java b/app/src/main/java/com/wireguard/android/util/RootShell.java index 205dd956..116fbd2c 100644 --- a/app/src/main/java/com/wireguard/android/util/RootShell.java +++ b/app/src/main/java/com/wireguard/android/util/RootShell.java @@ -13,7 +13,6 @@ import java.io.BufferedReader; import java.io.OutputStreamWriter; import java.io.InputStreamReader; import java.io.File; -import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.List; import java.util.UUID; @@ -29,10 +28,6 @@ import javax.inject.Inject; @ApplicationScope public class RootShell { private static final Pattern ERRNO_EXTRACTOR = Pattern.compile("error=(\\d+)"); - /** - * Setup commands that are run at the beginning of each root shell. The trap command ensures - * access to the return value of the last command, since su itself always exits with 0. - */ private static final String TAG = "WireGuard/" + RootShell.class.getSimpleName(); private static final String[][] libraryNamedExecutables = { {"libwg.so", "wg"}, @@ -179,7 +174,7 @@ public class RootShell { ++beginEnds; continue; } - if (line.startsWith(end) && line.length() > end.length()) { + if (line.startsWith(end) && line.length() > end.length() + 1) { errnoStdout = Integer.valueOf(line.substring(end.length() + 1)); ++beginEnds; break; @@ -197,7 +192,7 @@ public class RootShell { ++beginEnds; continue; } - if (line.startsWith(end) && line.length() > end.length()) { + if (line.startsWith(end) && line.length() > end.length() + 1) { errnoStderr = Integer.valueOf(line.substring(end.length() + 1)); ++beginEnds; break; |