Fix incorrect gid config leads to process/system cannot start.
We found that if the system application misconfigures the gid in the permissions, -1 will be added to the application's gid list, which will cause the application process or system startup to fail, so consider adding a check to prevent this unexpected situation.
Change-Id: Ic3133067285ecfd9310b4bca56ff402180e7c2aa
diff --git a/services/core/java/com/android/server/SystemConfig.java b/services/core/java/com/android/server/SystemConfig.java
index 79620cf..1c1190f 100644
--- a/services/core/java/com/android/server/SystemConfig.java
+++ b/services/core/java/com/android/server/SystemConfig.java
@@ -1638,7 +1638,13 @@
String gidStr = parser.getAttributeValue(null, "gid");
if (gidStr != null) {
int gid = Process.getGidForName(gidStr);
- perm.gids = appendInt(perm.gids, gid);
+ if (gid != -1) {
+ perm.gids = appendInt(perm.gids, gid);
+ } else {
+ Slog.w(TAG, "<group> with unknown gid \""
+ + gidStr + " for permission " + name + " in "
+ + parser.getPositionDescription());
+ }
} else {
Slog.w(TAG, "<group> without gid at "
+ parser.getPositionDescription());