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

Commit 4698f5cc authored by Jack Yu's avatar Jack Yu
Browse files

Fixed that bad address returned from network crashes the phone.

Added bad address handler to prevent the crash.

bug: 26920352
Change-Id: I58734b0fc08507ec18170a888b26347870214c66
parent 6dea04ab
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -159,7 +159,13 @@ public class DataCallResponse {
                                addrPrefixLen = (ia instanceof Inet4Address) ? 32 : 128;
                            }
                            if (DBG) Rlog.d(LOG_TAG, "addr/pl=" + addr + "/" + addrPrefixLen);
                            try {
                                la = new LinkAddress(ia, addrPrefixLen);
                            } catch (IllegalArgumentException e) {
                                throw new UnknownHostException("Bad parameter for LinkAddress, ia="
                                        + ia.getHostAddress() + "/" + addrPrefixLen);
                            }

                            linkProperties.addLinkAddress(la);
                        }
                    }
+11 −0
Original line number Diff line number Diff line
@@ -83,4 +83,15 @@ public class DataCallResponseTest extends TelephonyTest {

        assertEquals(mDcResponse.mtu, linkProperties.getMtu());
    }

    @Test
    @SmallTest
    public void testSetLinkPropertiesInvalidAddress() throws Exception {

        mDcResponse.addresses = new String[]{"224.224.224.224"};

        LinkProperties linkProperties = new LinkProperties();
        assertEquals(SetupResult.ERR_UnacceptableParameter,
                mDcResponse.setLinkProperties(linkProperties, true));
    }
}
 No newline at end of file