summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Robert Greenwalt <rgreenwalt@google.com> 2013-11-13 16:27:56 -0800
committer Android Git Automerger <android-git-automerger@android.com> 2013-11-13 16:27:56 -0800
commitec9e8933effe1dcb6887f7dca1cc0d78e6107e38 (patch)
tree5a7fcd4cbff9b2aae93d4223ffb43e3585f88869
parent84f4ad807152b6266431144425f153c48db28696 (diff)
parent3b9244b4b4d5008daa9763a169a751975c75cc54 (diff)
am 3b9244b4: Merge "Fix for the invalid Global Proxy Setting"
* commit '3b9244b4b4d5008daa9763a169a751975c75cc54': Fix for the invalid Global Proxy Setting
-rw-r--r--core/java/android/net/ProxyProperties.java10
-rw-r--r--services/java/com/android/server/ConnectivityService.java14
-rw-r--r--services/java/com/android/server/DevicePolicyManagerService.java7
3 files changed, 31 insertions, 0 deletions
diff --git a/core/java/android/net/ProxyProperties.java b/core/java/android/net/ProxyProperties.java
index 9c4772b90f5c..a4157c9225be 100644
--- a/core/java/android/net/ProxyProperties.java
+++ b/core/java/android/net/ProxyProperties.java
@@ -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) {
diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java
index 7c43c17af188..8c388edb149e 100644
--- a/services/java/com/android/server/ConnectivityService.java
+++ b/services/java/com/android/server/ConnectivityService.java
@@ -3138,6 +3138,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();
@@ -3171,6 +3176,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;
}
@@ -3194,6 +3204,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;
diff --git a/services/java/com/android/server/DevicePolicyManagerService.java b/services/java/com/android/server/DevicePolicyManagerService.java
index 7ecd2c0364e5..dfdde0ca6231 100644
--- a/services/java/com/android/server/DevicePolicyManagerService.java
+++ b/services/java/com/android/server/DevicePolicyManagerService.java
@@ -48,6 +48,7 @@ import android.content.pm.PackageManager;
import android.content.pm.Signature;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
+import android.net.ProxyProperties;
import android.net.Uri;
import android.os.Binder;
import android.os.Bundle;
@@ -2159,6 +2160,12 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
}
exclusionList = exclusionList.trim();
ContentResolver res = mContext.getContentResolver();
+
+ ProxyProperties proxyProperties = new ProxyProperties(data[0], proxyPort, exclusionList);
+ if (!proxyProperties.isValid()) {
+ Slog.e(TAG, "Invalid proxy properties, ignoring: " + proxyProperties.toString());
+ return;
+ }
Settings.Global.putString(res, Settings.Global.GLOBAL_HTTP_PROXY_HOST, data[0]);
Settings.Global.putInt(res, Settings.Global.GLOBAL_HTTP_PROXY_PORT, proxyPort);
Settings.Global.putString(res, Settings.Global.GLOBAL_HTTP_PROXY_EXCLUSION_LIST,