Merge "DO NOT MERGE: Add size check on PPS#policy" into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
23a890a43f
@@ -16,6 +16,9 @@
|
|||||||
|
|
||||||
package android.net.wifi.hotspot2.pps;
|
package android.net.wifi.hotspot2.pps;
|
||||||
|
|
||||||
|
import static android.net.wifi.hotspot2.PasspointConfiguration.MAX_NUMBER_OF_ENTRIES;
|
||||||
|
import static android.net.wifi.hotspot2.PasspointConfiguration.MAX_STRING_LENGTH;
|
||||||
|
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
@@ -269,11 +272,19 @@ public final class Policy implements Parcelable {
|
|||||||
*/
|
*/
|
||||||
public boolean validate() {
|
public boolean validate() {
|
||||||
if (TextUtils.isEmpty(mFqdn)) {
|
if (TextUtils.isEmpty(mFqdn)) {
|
||||||
Log.d(TAG, "Missing FQDN");
|
Log.e(TAG, "Missing FQDN");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (mFqdn.getBytes(StandardCharsets.UTF_8).length > MAX_STRING_LENGTH) {
|
||||||
|
Log.e(TAG, "FQDN is too long");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (TextUtils.isEmpty(mCountries)) {
|
if (TextUtils.isEmpty(mCountries)) {
|
||||||
Log.d(TAG, "Missing countries");
|
Log.e(TAG, "Missing countries");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (mCountries.getBytes(StandardCharsets.UTF_8).length > MAX_STRING_LENGTH) {
|
||||||
|
Log.e(TAG, "country is too long");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -449,7 +460,7 @@ public final class Policy implements Parcelable {
|
|||||||
}
|
}
|
||||||
for (String ssid : mExcludedSsidList) {
|
for (String ssid : mExcludedSsidList) {
|
||||||
if (ssid.getBytes(StandardCharsets.UTF_8).length > MAX_SSID_BYTES) {
|
if (ssid.getBytes(StandardCharsets.UTF_8).length > MAX_SSID_BYTES) {
|
||||||
Log.d(TAG, "Invalid SSID: " + ssid);
|
Log.e(TAG, "Invalid SSID: " + ssid);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -457,15 +468,24 @@ public final class Policy implements Parcelable {
|
|||||||
// Validate required protocol to port map.
|
// Validate required protocol to port map.
|
||||||
if (mRequiredProtoPortMap != null) {
|
if (mRequiredProtoPortMap != null) {
|
||||||
for (Map.Entry<Integer, String> entry : mRequiredProtoPortMap.entrySet()) {
|
for (Map.Entry<Integer, String> entry : mRequiredProtoPortMap.entrySet()) {
|
||||||
|
int protocol = entry.getKey();
|
||||||
|
if (protocol < 0 || protocol > 255) {
|
||||||
|
Log.e(TAG, "Invalid IP protocol: " + protocol);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
String portNumber = entry.getValue();
|
String portNumber = entry.getValue();
|
||||||
if (portNumber.getBytes(StandardCharsets.UTF_8).length > MAX_PORT_STRING_BYTES) {
|
if (portNumber.getBytes(StandardCharsets.UTF_8).length > MAX_PORT_STRING_BYTES) {
|
||||||
Log.d(TAG, "PortNumber string bytes exceeded the max: " + portNumber);
|
Log.e(TAG, "PortNumber string bytes exceeded the max: " + portNumber);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Validate preferred roaming partner list.
|
// Validate preferred roaming partner list.
|
||||||
if (mPreferredRoamingPartnerList != null) {
|
if (mPreferredRoamingPartnerList != null) {
|
||||||
|
if (mPreferredRoamingPartnerList.size() > MAX_NUMBER_OF_ENTRIES) {
|
||||||
|
Log.e(TAG, "Number of the Preferred Roaming Partner exceed the limit");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
for (RoamingPartner partner : mPreferredRoamingPartnerList) {
|
for (RoamingPartner partner : mPreferredRoamingPartnerList) {
|
||||||
if (!partner.validate()) {
|
if (!partner.validate()) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user