Fix for the invalid Global Proxy Setting

b/11598568

Adding validation for Global Proxy setting before it is
being set.

Proxy is validated at the boot time also to make sure
the value set is valid.

Change-Id: Ib93d24a80af1a329694f07c47bd81dfcc1e1b874
Signed-off-by: Raj Mamadgi <rmamadgi@sta.samsung.com>
This commit is contained in:
Raj Mamadgi
2013-11-11 13:52:58 -08:00
committed by Ankit Somani
parent 4e3475964b
commit 97eba6ba41
2 changed files with 24 additions and 0 deletions

View File

@@ -115,6 +115,16 @@ public class ProxyProperties implements Parcelable {
return false;
}
public boolean isValid() {
try {
Proxy.validate(mHost == null ? "" : mHost, mPort == 0 ? "" : Integer.toString(mPort),
mExclusionList == null ? "" : mExclusionList);
} catch (IllegalArgumentException e) {
return false;
}
return true;
}
public java.net.Proxy makeProxy() {
java.net.Proxy proxy = java.net.Proxy.NO_PROXY;
if (mHost != null) {

View File

@@ -3114,6 +3114,11 @@ public class ConnectivityService extends IConnectivityManager.Stub {
int port = 0;
String exclList = "";
if (proxyProperties != null && !TextUtils.isEmpty(proxyProperties.getHost())) {
if (!proxyProperties.isValid()) {
if (DBG)
log("Invalid proxy properties, ignoring: " + proxyProperties.toString());
return;
}
mGlobalProxy = new ProxyProperties(proxyProperties);
host = mGlobalProxy.getHost();
port = mGlobalProxy.getPort();
@@ -3147,6 +3152,11 @@ public class ConnectivityService extends IConnectivityManager.Stub {
Settings.Global.GLOBAL_HTTP_PROXY_EXCLUSION_LIST);
if (!TextUtils.isEmpty(host)) {
ProxyProperties proxyProperties = new ProxyProperties(host, port, exclList);
if (!proxyProperties.isValid()) {
if (DBG) log("Invalid proxy properties, ignoring: " + proxyProperties.toString());
return;
}
synchronized (mProxyLock) {
mGlobalProxy = proxyProperties;
}
@@ -3170,6 +3180,10 @@ public class ConnectivityService extends IConnectivityManager.Stub {
synchronized (mProxyLock) {
if (mDefaultProxy != null && mDefaultProxy.equals(proxy)) return;
if (mDefaultProxy == proxy) return; // catches repeated nulls
if (!proxy.isValid()) {
if (DBG) log("Invalid proxy properties, ignoring: " + proxy.toString());
return;
}
mDefaultProxy = proxy;
if (mGlobalProxy != null) return;