Bug 1117592 - Avoid use of single buffer as parameter and destination in snprintf in NetworkUtils.cpp. r=fabrice.
authorNicholas Nethercote <nnethercote@mozilla.com>
Mon, 05 Jan 2015 15:51:49 -0800
changeset 222189 91c3845c87cf82da7150c562d074c13999a63f44
parent 222188 5667902b8cbaa7936ae15050d378aa390c84cbb6
child 222190 eb0d05a27922366d578bbf274c48c0215045bf4d
push id28059
push userryanvm@gmail.com
push dateTue, 06 Jan 2015 15:53:01 +0000
treeherdermozilla-central@4d91c33b351c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfabrice
bugs1117592
milestone37.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1117592 - Avoid use of single buffer as parameter and destination in snprintf in NetworkUtils.cpp. r=fabrice.
dom/system/gonk/NetworkUtils.cpp
--- a/dom/system/gonk/NetworkUtils.cpp
+++ b/dom/system/gonk/NetworkUtils.cpp
@@ -804,23 +804,26 @@ void NetworkUtils::startTethering(Comman
 {
   char command[MAX_COMMAND_SIZE];
 
   // We don't need to start tethering again.
   // Send the dummy command to continue the function chain.
   if (aResult.mResultReason.Find("started") != kNotFound) {
     snprintf(command, MAX_COMMAND_SIZE - 1, "%s", DUMMY_COMMAND);
   } else {
-    snprintf(command, MAX_COMMAND_SIZE - 1, "tether start %s %s", GET_CHAR(mWifiStartIp), GET_CHAR(mWifiEndIp));
-
     // If usbStartIp/usbEndIp is not valid, don't append them since
     // the trailing white spaces will be parsed to extra empty args
     // See: http://androidxref.com/4.3_r2.1/xref/system/core/libsysutils/src/FrameworkListener.cpp#78
     if (!GET_FIELD(mUsbStartIp).IsEmpty() && !GET_FIELD(mUsbEndIp).IsEmpty()) {
-      snprintf(command, MAX_COMMAND_SIZE - 1, "%s %s %s", command, GET_CHAR(mUsbStartIp), GET_CHAR(mUsbEndIp));
+      snprintf(command, MAX_COMMAND_SIZE - 1, "tether start %s %s %s %s",
+               GET_CHAR(mWifiStartIp), GET_CHAR(mWifiEndIp),
+               GET_CHAR(mUsbStartIp),  GET_CHAR(mUsbEndIp));
+    } else {
+      snprintf(command, MAX_COMMAND_SIZE - 1, "tether start %s %s",
+               GET_CHAR(mWifiStartIp), GET_CHAR(mWifiEndIp));
     }
   }
 
   doCommand(command, aChain, aCallback);
 }
 
 void NetworkUtils::untetherInterface(CommandChain* aChain,
                                      CommandCallback aCallback,