From de8f0fef6438a31fb2885bbbb3c6c218f64fc676 Mon Sep 17 00:00:00 2001 From: "Nate(Qiang) Jiang" Date: Wed, 12 Apr 2023 18:32:50 +0000 Subject: DO NOT MERGE: Limit the ServiceFriendlyNames Bug: 274445194 Test: atest android.net.wifi Change-Id: Id4e16007531ba1ce3e3f9fa3d3111b5af57751be --- .../net/wifi/hotspot2/PasspointConfiguration.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/wifi/java/android/net/wifi/hotspot2/PasspointConfiguration.java b/wifi/java/android/net/wifi/hotspot2/PasspointConfiguration.java index 09f91d688f7b..a6509e3e9fe1 100644 --- a/wifi/java/android/net/wifi/hotspot2/PasspointConfiguration.java +++ b/wifi/java/android/net/wifi/hotspot2/PasspointConfiguration.java @@ -842,6 +842,23 @@ public final class PasspointConfiguration implements Parcelable { } } } + if (mServiceFriendlyNames != null) { + if (mServiceFriendlyNames.size() > MAX_NUMBER_OF_ENTRIES) { + Log.e(TAG, "ServiceFriendlyNames exceed the max!"); + return false; + } + for (Map.Entry names : mServiceFriendlyNames.entrySet()) { + if (names.getKey() == null || names.getValue() == null) { + Log.e(TAG, "Service friendly name entry should not be null"); + return false; + } + if (names.getKey().length() > MAX_STRING_LENGTH + || names.getValue().length() > MAX_STRING_LENGTH) { + Log.e(TAG, "Service friendly name is to long"); + return false; + } + } + } return true; } -- cgit v1.2.3-59-g8ed1b