1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-12-23 11:21:29 +00:00

Fix sending wrongly encoded commands into the unix subshell (fixes #1198) (#1199)

* Fix sending wrongly encoded commands into the unix subshell (fixes #1198)

This reverts commit 7541fa978e.
This commit is contained in:
Catfriend1 2018-07-28 01:05:41 +02:00 committed by GitHub
parent b99d6d47d4
commit 5426e750ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -15,9 +15,11 @@ import android.widget.Toast;
import com.nutomic.syncthingandroid.R; import com.nutomic.syncthingandroid.R;
import com.nutomic.syncthingandroid.service.Constants; import com.nutomic.syncthingandroid.service.Constants;
import java.io.BufferedWriter;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.IOException;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import eu.chainfire.libsuperuser.Shell; import eu.chainfire.libsuperuser.Shell;
@ -178,9 +180,10 @@ public class Util {
try { try {
shellProc = Runtime.getRuntime().exec((useRoot) ? "su" : "sh"); shellProc = Runtime.getRuntime().exec((useRoot) ? "su" : "sh");
shellOut = new DataOutputStream(shellProc.getOutputStream()); shellOut = new DataOutputStream(shellProc.getOutputStream());
BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(shellOut));
Log.d(TAG, "runShellCommand: " + cmd); Log.d(TAG, "runShellCommand: " + cmd);
shellOut.writeBytes(cmd); bufferedWriter.write(cmd);
shellOut.flush(); bufferedWriter.flush();
shellOut.close(); shellOut.close();
shellOut = null; shellOut = null;
exitCode = shellProc.waitFor(); exitCode = shellProc.waitFor();