Skip to content

Commit 3c11b22

Browse files
wifi sanitizing iface names
1 parent c184c79 commit 3c11b22

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

lib/util.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,7 @@ function sanitizeShellString(str, strict) {
709709
(strict && s[i] === '@') ||
710710
(strict && s[i] === ' ') ||
711711
(strict && s[i] == '{') ||
712+
(strict && s[i] == ';') ||
712713
(strict && s[i] == ')'))) {
713714
result = result + s[i];
714715
}

lib/wifi.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,15 @@ function wifiNetworks(callback) {
401401
}
402402
});
403403
if (iface) {
404-
const res = getWifiNetworkListIw(iface);
404+
let ifaceSanitized = '';
405+
const s = util.isPrototypePolluted() ? '---' : util.sanitizeShellString(iface);
406+
for (let i = 0; i <= util.mathMin(s.length, 2000); i++) {
407+
if (s[i] !== undefined) {
408+
ifaceSanitized = ifaceSanitized + s[i];
409+
}
410+
}
411+
412+
const res = getWifiNetworkListIw(ifaceSanitized);
405413
if (res === -1) {
406414
// try again after 4 secs
407415
setTimeout(function (iface) {
@@ -529,8 +537,16 @@ function wifiConnections(callback) {
529537
const ifaces = ifaceListLinux();
530538
const networkList = getWifiNetworkListNmi();
531539
ifaces.forEach(ifaceDetail => {
532-
const nmiDetails = nmiDeviceLinux(ifaceDetail.iface);
533-
const wpaDetails = wpaConnectionLinux(ifaceDetail.iface);
540+
let ifaceSanitized = '';
541+
const s = util.isPrototypePolluted() ? '---' : util.sanitizeShellString(ifaceDetail.iface);
542+
for (let i = 0; i <= util.mathMin(s.length, 2000); i++) {
543+
if (s[i] !== undefined) {
544+
ifaceSanitized = ifaceSanitized + s[i];
545+
}
546+
}
547+
548+
const nmiDetails = nmiDeviceLinux(ifaceSanitized);
549+
const wpaDetails = wpaConnectionLinux(ifaceSanitized);
534550
const ssid = nmiDetails.ssid || wpaDetails.ssid;
535551
const network = networkList.filter(nw => nw.ssid === ssid);
536552
const nmiConnection = nmiConnectionLinux(ssid);

0 commit comments

Comments
 (0)