Skip to content

Commit

Permalink
wifi sanitizing iface names
Browse files Browse the repository at this point in the history
  • Loading branch information
sebhildebrandt committed Sep 19, 2023
1 parent c184c79 commit 3c11b22
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,7 @@ function sanitizeShellString(str, strict) {
(strict && s[i] === '@') ||
(strict && s[i] === ' ') ||
(strict && s[i] == '{') ||
(strict && s[i] == ';') ||
(strict && s[i] == ')'))) {
result = result + s[i];
}
Expand Down
22 changes: 19 additions & 3 deletions lib/wifi.js
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,15 @@ function wifiNetworks(callback) {
}
});
if (iface) {
const res = getWifiNetworkListIw(iface);
let ifaceSanitized = '';
const s = util.isPrototypePolluted() ? '---' : util.sanitizeShellString(iface);
for (let i = 0; i <= util.mathMin(s.length, 2000); i++) {
if (s[i] !== undefined) {
ifaceSanitized = ifaceSanitized + s[i];
}
}

const res = getWifiNetworkListIw(ifaceSanitized);
if (res === -1) {
// try again after 4 secs
setTimeout(function (iface) {
Expand Down Expand Up @@ -529,8 +537,16 @@ function wifiConnections(callback) {
const ifaces = ifaceListLinux();
const networkList = getWifiNetworkListNmi();
ifaces.forEach(ifaceDetail => {
const nmiDetails = nmiDeviceLinux(ifaceDetail.iface);
const wpaDetails = wpaConnectionLinux(ifaceDetail.iface);
let ifaceSanitized = '';
const s = util.isPrototypePolluted() ? '---' : util.sanitizeShellString(ifaceDetail.iface);
for (let i = 0; i <= util.mathMin(s.length, 2000); i++) {
if (s[i] !== undefined) {
ifaceSanitized = ifaceSanitized + s[i];
}
}

const nmiDetails = nmiDeviceLinux(ifaceSanitized);
const wpaDetails = wpaConnectionLinux(ifaceSanitized);
const ssid = nmiDetails.ssid || wpaDetails.ssid;
const network = networkList.filter(nw => nw.ssid === ssid);
const nmiConnection = nmiConnectionLinux(ssid);
Expand Down

0 comments on commit 3c11b22

Please sign in to comment.