mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-12-28 13:51:30 +00:00
Fix sending wrongly encoded commands into the unix subshell (fixes #1198)
This commit is contained in:
parent
6a459311f4
commit
3967e863f5
1 changed files with 6 additions and 10 deletions
|
@ -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;
|
||||||
|
@ -139,13 +141,6 @@ public class Util {
|
||||||
useRoot = true;
|
useRoot = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for cyrillic characters in the folder path.
|
|
||||||
if (absoluteFolderPath.matches(".*\\p{InCyrillic}.*")) {
|
|
||||||
Log.w(TAG, "nativeBinaryCanWriteToPath: Path '" + absoluteFolderPath +
|
|
||||||
"' contains cyrillic characters. As this is currently not handled, we'll return true without checking permissions.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write permission test file.
|
// Write permission test file.
|
||||||
String touchFile = absoluteFolderPath + "/" + TOUCH_FILE_NAME;
|
String touchFile = absoluteFolderPath + "/" + TOUCH_FILE_NAME;
|
||||||
int exitCode = runShellCommand("echo \"\" > \"" + touchFile + "\"\n", useRoot);
|
int exitCode = runShellCommand("echo \"\" > \"" + touchFile + "\"\n", useRoot);
|
||||||
|
@ -185,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();
|
||||||
|
|
Loading…
Reference in a new issue