Prevent forwarding to privileged ports

Closes #345
This commit is contained in:
M66B 2016-02-26 10:24:52 +01:00
parent b43f6971c3
commit da00526ec1
2 changed files with 9 additions and 0 deletions

View File

@ -49,6 +49,11 @@ public class ActivityForwardApproval extends Activity {
final int ruid = getIntent().getIntExtra("ruid", 0);
final String raddr = (addr == null ? "127.0.0.1" : addr);
if (rport < 1024) {
Log.w(TAG, "Port forwarding to privileged port not possible");
finish();
}
String pname;
if (protocol == 6)
pname = getString(R.string.menu_protocol_tcp);

View File

@ -194,6 +194,10 @@ public class ActivityForwarding extends AppCompatActivity {
final String raddr = etRAddr.getText().toString();
final int rport = Integer.parseInt(etRPort.getText().toString());
final int ruid = ((Rule) spRuid.getSelectedItem()).info.applicationInfo.uid;
if (rport < 1024)
throw new IllegalArgumentException("Port forwarding to privileged port not possible");
new AsyncTask<Object, Object, Throwable>() {
@Override
protected Throwable doInBackground(Object... objects) {