diff options
author | Irfan Sheriff <isheriff@google.com> | 2010-05-24 14:55:42 -0700 |
---|---|---|
committer | Irfan Sheriff <isheriff@google.com> | 2010-05-24 14:55:42 -0700 |
commit | a6e559edb73886c626e0e5a95085d0ead767ceb7 (patch) | |
tree | 3a94d3306d39e27585f1d3ee217b03ba4d895584 /services/java/com/android/server | |
parent | c7c7afd7a1af36e787266815487f4600196406b8 (diff) | |
download | frameworks_base-a6e559edb73886c626e0e5a95085d0ead767ceb7.zip frameworks_base-a6e559edb73886c626e0e5a95085d0ead767ceb7.tar.gz frameworks_base-a6e559edb73886c626e0e5a95085d0ead767ceb7.tar.bz2 |
Fix escaping of characters
\ and " in SSID and password cause issues
with netd parsing. Fix it.
Bug: 2708960
Change-Id: I278ca21c0bbfd9dc430a2f9ae02828274a0d2376
Diffstat (limited to 'services/java/com/android/server')
-rw-r--r-- | services/java/com/android/server/NetworkManagementService.java | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/services/java/com/android/server/NetworkManagementService.java b/services/java/com/android/server/NetworkManagementService.java index 552bed4..5e0439c 100644 --- a/services/java/com/android/server/NetworkManagementService.java +++ b/services/java/com/android/server/NetworkManagementService.java @@ -494,15 +494,20 @@ class NetworkManagementService extends INetworkManagementService.Stub { * argv8 - Max SCB */ String str = String.format("softap set " + wlanIface + " " + softapIface + - " \"%s\" %s %s", wifiConfig.SSID, + " %s %s %s", convertQuotedString(wifiConfig.SSID), wifiConfig.allowedKeyManagement.get(KeyMgmt.WPA_PSK) ? "wpa2-psk" : "open", - wifiConfig.preSharedKey); + convertQuotedString(wifiConfig.preSharedKey)); mConnector.doCommand(str); } mConnector.doCommand(String.format("softap startap")); } + private String convertQuotedString(String s) { + /* Replace \ with \\, then " with \" and add quotes at end */ + return '"' + s.replaceAll("\\\\","\\\\\\\\").replaceAll("\"","\\\\\"") + '"'; + } + public void stopAccessPoint() throws IllegalStateException { mContext.enforceCallingOrSelfPermission( android.Manifest.permission.CHANGE_NETWORK_STATE, "NetworkManagementService"); @@ -521,10 +526,10 @@ class NetworkManagementService extends INetworkManagementService.Stub { mConnector.doCommand(String.format("softap set " + wlanIface + " " + softapIface)); } else { String str = String.format("softap set " + wlanIface + " " + softapIface + - " \"%s\" %s %s", wifiConfig.SSID, + " %s %s %s", convertQuotedString(wifiConfig.SSID), wifiConfig.allowedKeyManagement.get(KeyMgmt.WPA_PSK) ? "wpa2-psk" : "open", - wifiConfig.preSharedKey); + convertQuotedString(wifiConfig.preSharedKey)); mConnector.doCommand(str); } } |