Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4b8fabd5 authored by Robert Greenwalt's avatar Robert Greenwalt
Browse files

Fix crash bug with mismatched iface names

The copied-to LinkProperties needs the same iface name as the copied from.
Since we were copying into an empty LP this was trivial, but I
changed the params to tighten up this contract - don't want to
accidentally change an LP's iface name when we shouldn't.

bug:8569797
Change-Id: I5f88826e37271a0549c14d004bb2f16983b950e6
parent c4ad3cb0
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -1196,7 +1196,7 @@ class WifiConfigStore {
            WifiConfiguration newConfig) {
        boolean ipChanged = false;
        boolean proxyChanged = false;
        LinkProperties linkProperties = new LinkProperties();
        LinkProperties linkProperties = null;

        switch (newConfig.ipAssignment) {
            case STATIC:
@@ -1262,10 +1262,10 @@ class WifiConfigStore {
        }

        if (!ipChanged) {
            addIpSettingsFromConfig(linkProperties, currentConfig);
            linkProperties = copyIpSettingsFromConfig(currentConfig);
        } else {
            currentConfig.ipAssignment = newConfig.ipAssignment;
            addIpSettingsFromConfig(linkProperties, newConfig);
            linkProperties = copyIpSettingsFromConfig(newConfig);
            log("IP config changed SSID = " + currentConfig.SSID + " linkProperties: " +
                    linkProperties.toString());
        }
@@ -1291,8 +1291,9 @@ class WifiConfigStore {
        return new NetworkUpdateResult(ipChanged, proxyChanged);
    }

    private void addIpSettingsFromConfig(LinkProperties linkProperties,
            WifiConfiguration config) {
    private LinkProperties copyIpSettingsFromConfig(WifiConfiguration config) {
        LinkProperties linkProperties = new LinkProperties();
        linkProperties.setInterfaceName(config.linkProperties.getInterfaceName());
        for (LinkAddress linkAddr : config.linkProperties.getLinkAddresses()) {
            linkProperties.addLinkAddress(linkAddr);
        }
@@ -1302,6 +1303,7 @@ class WifiConfigStore {
        for (InetAddress dns : config.linkProperties.getDnses()) {
            linkProperties.addDns(dns);
        }
        return linkProperties;
    }

    /**