diff options
author | Lorenzo Colitti <lorenzo@google.com> | 2015-10-29 15:21:54 +0900 |
---|---|---|
committer | The Android Automerger <android-build@google.com> | 2015-10-29 19:24:57 -0700 |
commit | 9abc2aa7ede96685c518a8389a876096bb4299dc (patch) | |
tree | c75095a9dbeeb0e0425c9ea1ead6a74d7448f92c /services | |
parent | 2658cb002abae9341c9a82bfeaed764ba5bf97c8 (diff) | |
download | frameworks_base-9abc2aa7ede96685c518a8389a876096bb4299dc.zip frameworks_base-9abc2aa7ede96685c518a8389a876096bb4299dc.tar.gz frameworks_base-9abc2aa7ede96685c518a8389a876096bb4299dc.tar.bz2 |
Don't crash if a DHCP server doesn't send the server ID option.
This violates a MUST in RFC2131, but apparently some
implementations don't know or care.
Bug: 25343517
Change-Id: I80459b58ffe231e7ed64e77bafa157a96b745149
Diffstat (limited to 'services')
-rw-r--r-- | services/net/java/android/net/dhcp/DhcpClient.java | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/services/net/java/android/net/dhcp/DhcpClient.java b/services/net/java/android/net/dhcp/DhcpClient.java index 28cb114..c9efc69 100644 --- a/services/net/java/android/net/dhcp/DhcpClient.java +++ b/services/net/java/android/net/dhcp/DhcpClient.java @@ -417,9 +417,10 @@ public class DhcpClient extends BaseDhcpStateMachine { encap, mTransactionId, getSecs(), clientAddress, DO_UNICAST, mHwAddr, requestedAddress, serverAddress, REQUESTED_PARAMS, null); + String serverStr = (serverAddress != null) ? serverAddress.getHostAddress() : null; String description = "DHCPREQUEST ciaddr=" + clientAddress.getHostAddress() + " request=" + requestedAddress.getHostAddress() + - " to=" + serverAddress.getHostAddress(); + " serverid=" + serverStr; return transmitPacket(packet, description, to); } @@ -822,7 +823,8 @@ public class DhcpClient extends BaseDhcpStateMachine { public void enter() { super.enter(); if (!setIpAddress(mDhcpLease.ipAddress) || - !connectUdpSock((mDhcpLease.serverAddress))) { + (mDhcpLease.serverAddress != null && + !connectUdpSock((mDhcpLease.serverAddress)))) { notifyFailure(); // There's likely no point in going into DhcpInitState here, we'll probably just // repeat the transaction, get the same IP address as before, and fail. @@ -878,11 +880,15 @@ public class DhcpClient extends BaseDhcpStateMachine { } protected boolean sendPacket() { + // Not specifying a SERVER_IDENTIFIER option is a violation of RFC 2131, but... + // http://b/25343517 . Try to make things work anyway by using broadcast renews. + Inet4Address to = (mDhcpLease.serverAddress != null) ? + mDhcpLease.serverAddress : INADDR_BROADCAST; return sendRequestPacket( (Inet4Address) mDhcpLease.ipAddress.getAddress(), // ciaddr INADDR_ANY, // DHCP_REQUESTED_IP - INADDR_ANY, // DHCP_SERVER_IDENTIFIER - (Inet4Address) mDhcpLease.serverAddress); // packet destination address + null, // DHCP_SERVER_IDENTIFIER + to); // packet destination address } protected void receivePacket(DhcpPacket packet) { |