From 1cb8cdaf63f970533ef80b48ff713ed7c5b120f0 Mon Sep 17 00:00:00 2001 From: Etan Cohen Date: Fri, 20 Jul 2018 16:53:00 -0700 Subject: [RTT] Add NPE checks for invalid MAC addresses from Aware RTT requests for Aware peers may use PeerHandles. The RTT service queries the Aware service for their corresponding MAC addresses. In some corner cases, e.g. the Aware peer just disappeared, a null MAC address may be returned. This was not handled, resulting in an NPE. Bug: 111646773 Test: new unit test added, passes Change-Id: I7d7c37322848fe7e7dd4f9f412f1e1339321e9a8 --- service/java/com/android/server/wifi/rtt/RttServiceImpl.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'service') diff --git a/service/java/com/android/server/wifi/rtt/RttServiceImpl.java b/service/java/com/android/server/wifi/rtt/RttServiceImpl.java index 75e75aa0f..258bdb67f 100644 --- a/service/java/com/android/server/wifi/rtt/RttServiceImpl.java +++ b/service/java/com/android/server/wifi/rtt/RttServiceImpl.java @@ -1016,8 +1016,14 @@ public class RttServiceImpl extends IWifiRttManager.Stub { RangingRequest.Builder newRequestBuilder = new RangingRequest.Builder(); for (ResponderConfig rttPeer : request.request.mRttPeers) { if (rttPeer.peerHandle != null && rttPeer.macAddress == null) { + byte[] mac = peerIdToMacMap.get(rttPeer.peerHandle.peerId); + if (mac == null || mac.length != 6) { + Log.e(TAG, "processReceivedAwarePeerMacAddresses: received an invalid MAC " + + "address for peerId=" + rttPeer.peerHandle.peerId); + continue; + } newRequestBuilder.addResponder(new ResponderConfig( - MacAddress.fromBytes(peerIdToMacMap.get(rttPeer.peerHandle.peerId)), + MacAddress.fromBytes(mac), rttPeer.peerHandle, rttPeer.responderType, rttPeer.supports80211mc, rttPeer.channelWidth, rttPeer.frequency, rttPeer.centerFreq0, rttPeer.centerFreq1, rttPeer.preamble)); -- cgit v1.2.3