summaryrefslogtreecommitdiffstats
path: root/services/net
diff options
context:
space:
mode:
authorErik Kline <ek@google.com>2015-10-06 18:43:17 +0900
committerLorenzo Colitti <lorenzo@google.com>2015-10-08 15:40:41 +0900
commitb19238c48814c5a1438b1238794e121876ae89ab (patch)
treeed0c37d5646305f716bfbb644609ae3deb4ed043 /services/net
parent496906ee7008b72619f230c65f103533d4d2d68a (diff)
downloadframeworks_base-b19238c48814c5a1438b1238794e121876ae89ab.zip
frameworks_base-b19238c48814c5a1438b1238794e121876ae89ab.tar.gz
frameworks_base-b19238c48814c5a1438b1238794e121876ae89ab.tar.bz2
Accept DHCP responses from non-67 server source ports
Bug: 24687559 Change-Id: I5f03b8b2780c558281d8a50d0893fd64f2812add
Diffstat (limited to 'services/net')
-rw-r--r--services/net/java/android/net/dhcp/DhcpPacket.java16
1 files changed, 14 insertions, 2 deletions
diff --git a/services/net/java/android/net/dhcp/DhcpPacket.java b/services/net/java/android/net/dhcp/DhcpPacket.java
index 492d190..d654089 100644
--- a/services/net/java/android/net/dhcp/DhcpPacket.java
+++ b/services/net/java/android/net/dhcp/DhcpPacket.java
@@ -673,6 +673,14 @@ abstract class DhcpPacket {
return new String(bytes, 0, length, StandardCharsets.US_ASCII);
}
+ private static boolean isPacketToOrFromClient(short udpSrcPort, short udpDstPort) {
+ return (udpSrcPort == DHCP_CLIENT) || (udpDstPort == DHCP_CLIENT);
+ }
+
+ private static boolean isPacketServerToServer(short udpSrcPort, short udpDstPort) {
+ return (udpSrcPort == DHCP_SERVER) && (udpDstPort == DHCP_SERVER);
+ }
+
public static class ParseException extends Exception {
public ParseException(String msg, Object... args) {
super(String.format(msg, args));
@@ -791,8 +799,12 @@ abstract class DhcpPacket {
short udpLen = packet.getShort();
short udpChkSum = packet.getShort();
- if ((udpSrcPort != DHCP_SERVER) && (udpSrcPort != DHCP_CLIENT)) {
- throw new ParseException("Invalid source port %d", udpSrcPort);
+ // Only accept packets to or from the well-known client port (expressly permitting
+ // packets from ports other than the well-known server port; http://b/24687559), and
+ // server-to-server packets, e.g. for relays.
+ if (!isPacketToOrFromClient(udpSrcPort, udpDstPort) &&
+ !isPacketServerToServer(udpSrcPort, udpDstPort)) {
+ return null;
}
}