From 89aa6fb4d87b5a279150f15ad1f9bcfa03e3a261 Mon Sep 17 00:00:00 2001 From: Hugo Benichi Date: Tue, 11 Oct 2016 11:39:39 +0900 Subject: [PATCH] DhcpClient: guard against failure to parse packets DhcpPacket.decodeFullPacket() is not exception safe and can throw various runtime exceptions when trying to parse malicious or malformed packets. This patch adds a generic catch-all-exception in DhcpClient to avoid propagating the exception and killing the framework process on reception of such malformed packets. Bug: 31850211 Change-Id: I2e723a792ff067ada2834da875700d4df16c5159 --- services/net/java/android/net/dhcp/DhcpClient.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/services/net/java/android/net/dhcp/DhcpClient.java b/services/net/java/android/net/dhcp/DhcpClient.java index 9ee9cf4fbcc6..87e4edc5ef1d 100644 --- a/services/net/java/android/net/dhcp/DhcpClient.java +++ b/services/net/java/android/net/dhcp/DhcpClient.java @@ -43,6 +43,7 @@ import android.os.SystemClock; import android.system.ErrnoException; import android.system.Os; import android.system.PacketSocketAddress; +import android.util.EventLog; import android.util.Log; import android.util.TimeUtils; @@ -359,6 +360,14 @@ public class DhcpClient extends BaseDhcpStateMachine { if (!stopped) { Log.e(TAG, "Read error", e); } + } catch (Exception e) { + // SafetyNet logging for b/31850211 + int snetTagId = 0x534e4554; + String bugId = "31850211"; + int uid = -1; + String data = e.getClass().getName(); + EventLog.writeEvent(snetTagId, bugId, uid, data); + Log.e(TAG, "Failed to parse DHCP packet", e); } } maybeLog("Receive thread stopped"); -- 2.11.0