Validate package name passed to setApplicationRestrictions.
This adds validation that the package name passed to setApplicationRestrictions is in the correct format. This will avoid an issue where a path could be entered resulting in a file being written to an unexpected place. Bug: 239701237 Test: atest ApplicationRestrictionsTest Change-Id: I1ab2b7228470f10ec26fe3a608ae540cfc9e9a96
This commit is contained in:
@@ -54,6 +54,7 @@ import android.content.pm.ShortcutServiceInternal;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.content.pm.UserInfo.UserInfoFlag;
|
||||
import android.content.pm.UserProperties;
|
||||
import android.content.pm.parsing.FrameworkParsingPackageUtils;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
@@ -5368,6 +5369,11 @@ public class UserManagerService extends IUserManager.Stub {
|
||||
public void setApplicationRestrictions(String packageName, Bundle restrictions,
|
||||
@UserIdInt int userId) {
|
||||
checkSystemOrRoot("set application restrictions");
|
||||
String validationResult =
|
||||
FrameworkParsingPackageUtils.validateName(packageName, false, false);
|
||||
if (validationResult != null) {
|
||||
throw new IllegalArgumentException("Invalid package name: " + validationResult);
|
||||
}
|
||||
if (restrictions != null) {
|
||||
restrictions.setDefusable(true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user