mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-11 18:29:05 +01:00
Validate remote address.
This commit is contained in:
@@ -11,6 +11,7 @@ import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import static org.briarproject.bramble.api.plugin.BluetoothConstants.PROP_ADDRESS;
|
||||
import static org.briarproject.bramble.util.AndroidUtils.isValidBluetoothAddress;
|
||||
|
||||
@NotNullByDefault
|
||||
class AndroidBluetoothTransportConnection
|
||||
@@ -25,7 +26,8 @@ class AndroidBluetoothTransportConnection
|
||||
super(plugin);
|
||||
this.connectionManager = connectionManager;
|
||||
this.socket = socket;
|
||||
remote.put(PROP_ADDRESS, socket.getRemoteDevice().getAddress());
|
||||
String address = socket.getRemoteDevice().getAddress();
|
||||
if (isValidBluetoothAddress(address)) remote.put(PROP_ADDRESS, address);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -71,7 +71,7 @@ public class AndroidUtils {
|
||||
return new Pair<>("", "");
|
||||
}
|
||||
|
||||
private static boolean isValidBluetoothAddress(@Nullable String address) {
|
||||
public static boolean isValidBluetoothAddress(@Nullable String address) {
|
||||
return !StringUtils.isNullOrEmpty(address)
|
||||
&& BluetoothAdapter.checkBluetoothAddress(address)
|
||||
&& !address.equals(FAKE_BLUETOOTH_ADDRESS);
|
||||
|
||||
Reference in New Issue
Block a user