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

Commit cdb84d2f authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Fix bug in MacAddress.fromString()"

parents 1a2a4566 d2c5b192
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -280,9 +280,8 @@ public final class MacAddress implements Parcelable {
            throw new IllegalArgumentException(addr + " was not a valid MAC address");
        }
        long longAddr = 0;
        int index = ETHER_ADDR_LEN;
        while (index-- > 0) {
            int x = Integer.valueOf(parts[index], 16);
        for (int i = 0; i < parts.length; i++) {
            int x = Integer.valueOf(parts[i], 16);
            if (x < 0 || 0xff < x) {
                throw new IllegalArgumentException(addr + "was not a valid MAC address");
            }
+3 −0
Original line number Diff line number Diff line
@@ -161,6 +161,9 @@ public class MacAddressTest {

            assertEquals(mac, MacAddress.fromString(stringRepr));
            assertEquals(mac, MacAddress.fromBytes(bytesRepr));

            assertEquals(mac, MacAddress.fromString(MacAddress.stringAddrFromByteAddr(bytesRepr)));
            assertEquals(mac, MacAddress.fromBytes(MacAddress.byteAddrFromStringAddr(stringRepr)));
        }
    }