Bug 1068468 - Truncate ssid if its length of encoded to utf8 is longer than 32. r=chulee, a=bajaj
authorKai-Zhen Li <kli@mozilla.com>
Fri, 26 Sep 2014 17:41:19 +0800
changeset 225289 8e76e4e3735a98022e0ae4bf6baaae3cf98024f6
parent 225288 7f3c5ce2fd361f229740fe95655d5e3021ba0e51
child 225290 03e24668036e60f0e0317b69704ea7b77f7075c9
push id3979
push userraliiev@mozilla.com
push dateMon, 13 Oct 2014 16:35:44 +0000
treeherdermozilla-beta@30f2cc610691 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerschulee, bajaj
bugs1068468
milestone34.0a2
Bug 1068468 - Truncate ssid if its length of encoded to utf8 is longer than 32. r=chulee, a=bajaj
dom/wifi/WifiWorker.js
--- a/dom/wifi/WifiWorker.js
+++ b/dom/wifi/WifiWorker.js
@@ -3061,16 +3061,22 @@ WifiWorker.prototype = {
     dns1 = this.tetheringSettings[SETTINGS_WIFI_DNS1];
     dns2 = this.tetheringSettings[SETTINGS_WIFI_DNS2];
 
     // Check the format to prevent netd from crash.
     if (!ssid || ssid == "") {
       debug("Invalid SSID value.");
       return null;
     }
+    // Truncate ssid if its length of encoded to utf8 is longer than 32.
+    while (unescape(encodeURIComponent(ssid)).length > 32)
+    {
+      ssid = ssid.substring(0, ssid.length-1);
+    }
+
     if (securityType != WIFI_SECURITY_TYPE_NONE &&
         securityType != WIFI_SECURITY_TYPE_WPA_PSK &&
         securityType != WIFI_SECURITY_TYPE_WPA2_PSK) {
 
       debug("Invalid security type.");
       return null;
     }
     if (securityType != WIFI_SECURITY_TYPE_NONE && !securityId) {