wifi sanitizing iface names

This commit is contained in:
Sebastian Hildebrandt 2023-09-19 15:52:20 +02:00
parent c184c79f84
commit 3c11b2200d
2 changed files with 20 additions and 3 deletions

View File

@ -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];
}

View File

@ -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) {
@ -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);