Program: 192713
Project: 192713
Buggy source:
private void readPermissionsFromXml(File permFile,int permissionFlag){
  FileReader permReader=null;
  try {
    permReader=new FileReader(permFile);
  }
 catch (  FileNotFoundException e) {
    Slog.w(TAG,"String_Node_Str" + permFile);
    return;
  }
  final boolean lowRam=ActivityManager.isLowRamDeviceStatic();
  try {
    XmlPullParser parser=Xml.newPullParser();
    parser.setInput(permReader);
    int type;
    while ((type=parser.next()) != parser.START_TAG && type != parser.END_DOCUMENT) {
      ;
    }
    if (type != parser.START_TAG) {
      throw new XmlPullParserException("String_Node_Str");
    }
    if (!parser.getName().equals("String_Node_Str") && !parser.getName().equals("String_Node_Str")) {
      throw new XmlPullParserException("String_Node_Str" + permFile + "String_Node_Str"+ parser.getName()+ "String_Node_Str");
    }
    boolean allowAll=permissionFlag == ALLOW_ALL;
    boolean allowLibs=(permissionFlag & ALLOW_LIBS) != 0;
    boolean allowFeatures=(permissionFlag & ALLOW_FEATURES) != 0;
    boolean allowPermissions=(permissionFlag & ALLOW_PERMISSIONS) != 0;
    boolean allowAppConfigs=(permissionFlag & ALLOW_APP_CONFIGS) != 0;
    while (true) {
      XmlUtils.nextElement(parser);
      if (parser.getEventType() == XmlPullParser.END_DOCUMENT) {
        break;
      }
      String name=parser.getName();
      if ("String_Node_Str".equals(name) && allowAll) {
        String gidStr=parser.getAttributeValue(null,"String_Node_Str");
        if (gidStr != null) {
          int gid=android.os.Process.getGidForName(gidStr);
          mGlobalGids=appendInt(mGlobalGids,gid);
        }
 else {
          Slog.w(TAG,"String_Node_Str" + permFile + "String_Node_Str"+ parser.getPositionDescription());
        }
        XmlUtils.skipCurrentTag(parser);
        continue;
      }
 else       if ("String_Node_Str".equals(name) && allowPermissions) {
        String perm=parser.getAttributeValue(null,"String_Node_Str");
        if (perm == null) {
          Slog.w(TAG,"String_Node_Str" + permFile + "String_Node_Str"+ parser.getPositionDescription());
          XmlUtils.skipCurrentTag(parser);
          continue;
        }
        perm=perm.intern();
        readPermission(parser,perm);
      }
 else       if ("String_Node_Str".equals(name) && allowPermissions) {
        String perm=parser.getAttributeValue(null,"String_Node_Str");
        if (perm == null) {
          Slog.w(TAG,"String_Node_Str" + permFile + "String_Node_Str"+ parser.getPositionDescription());
          XmlUtils.skipCurrentTag(parser);
          continue;
        }
        String uidStr=parser.getAttributeValue(null,"String_Node_Str");
        if (uidStr == null) {
          Slog.w(TAG,"String_Node_Str" + permFile + "String_Node_Str"+ parser.getPositionDescription());
          XmlUtils.skipCurrentTag(parser);
          continue;
        }
        int uid=Process.getUidForName(uidStr);
        if (uid < 0) {
          Slog.w(TAG,"String_Node_Str" + uidStr + "String_Node_Str"+ permFile+ "String_Node_Str"+ parser.getPositionDescription());
          XmlUtils.skipCurrentTag(parser);
          continue;
        }
        perm=perm.intern();
        ArraySet<String> perms=mSystemPermissions.get(uid);
        if (perms == null) {
          perms=new ArraySet<String>();
          mSystemPermissions.put(uid,perms);
        }
        perms.add(perm);
        XmlUtils.skipCurrentTag(parser);
      }
 else       if ("String_Node_Str".equals(name) && allowLibs) {
        String lname=parser.getAttributeValue(null,"String_Node_Str");
        String lfile=parser.getAttributeValue(null,"String_Node_Str");
        if (lname == null) {
          Slog.w(TAG,"String_Node_Str" + permFile + "String_Node_Str"+ parser.getPositionDescription());
        }
 else         if (lfile == null) {
          Slog.w(TAG,"String_Node_Str" + permFile + "String_Node_Str"+ parser.getPositionDescription());
        }
 else {
          mSharedLibraries.put(lname,lfile);
        }
        XmlUtils.skipCurrentTag(parser);
        continue;
      }
 else       if ("String_Node_Str".equals(name) && allowFeatures) {
        String fname=parser.getAttributeValue(null,"String_Node_Str");
        int fversion=XmlUtils.readIntAttribute(null,"String_Node_Str",0);
        boolean allowed;
        if (!lowRam) {
          allowed=true;
        }
 else {
          String notLowRam=parser.getAttributeValue(null,"String_Node_Str");
          allowed=!"String_Node_Str".equals(notLowRam);
        }
        if (fname == null) {
          Slog.w(TAG,"String_Node_Str" + permFile + "String_Node_Str"+ parser.getPositionDescription());
        }
 else         if (allowed) {
          addFeature(fname,fversion);
        }
        XmlUtils.skipCurrentTag(parser);
        continue;
      }
 else       if ("String_Node_Str".equals(name) && allowFeatures) {
        String fname=parser.getAttributeValue(null,"String_Node_Str");
        if (fname == null) {
          Slog.w(TAG,"String_Node_Str" + permFile + "String_Node_Str"+ parser.getPositionDescription());
        }
 else {
          mUnavailableFeatures.add(fname);
        }
        XmlUtils.skipCurrentTag(parser);
        continue;
      }
 else       if ("String_Node_Str".equals(name) && allowAll) {
        String pkgname=parser.getAttributeValue(null,"String_Node_Str");
        if (pkgname == null) {
          Slog.w(TAG,"String_Node_Str" + permFile + "String_Node_Str"+ parser.getPositionDescription());
        }
 else {
          mAllowInPowerSaveExceptIdle.add(pkgname);
        }
        XmlUtils.skipCurrentTag(parser);
        continue;
      }
 else       if ("String_Node_Str".equals(name) && allowAll) {
        String pkgname=parser.getAttributeValue(null,"String_Node_Str");
        if (pkgname == null) {
          Slog.w(TAG,"String_Node_Str" + permFile + "String_Node_Str"+ parser.getPositionDescription());
        }
 else {
          mAllowInPowerSave.add(pkgname);
        }
        XmlUtils.skipCurrentTag(parser);
        continue;
      }
 else       if ("String_Node_Str".equals(name) && allowAll) {
        String pkgname=parser.getAttributeValue(null,"String_Node_Str");
        if (pkgname == null) {
          Slog.w(TAG,"String_Node_Str" + permFile + "String_Node_Str"+ parser.getPositionDescription());
        }
 else {
          mFixedImeApps.add(pkgname);
        }
        XmlUtils.skipCurrentTag(parser);
        continue;
      }
 else       if ("String_Node_Str".equals(name) && allowAppConfigs) {
        String pkgname=parser.getAttributeValue(null,"String_Node_Str");
        if (pkgname == null) {
          Slog.w(TAG,"String_Node_Str" + permFile + "String_Node_Str"+ parser.getPositionDescription());
        }
 else {
          mLinkedApps.add(pkgname);
        }
        XmlUtils.skipCurrentTag(parser);
      }
 else       if ("String_Node_Str".equals(name) && allowAppConfigs) {
        String pkgname=parser.getAttributeValue(null,"String_Node_Str");
        if (pkgname == null) {
          Slog.w(TAG,"String_Node_Str" + permFile + "String_Node_Str"+ parser.getPositionDescription());
        }
 else {
          mSystemUserWhitelistedApps.add(pkgname);
        }
        XmlUtils.skipCurrentTag(parser);
      }
 else       if ("String_Node_Str".equals(name) && allowAppConfigs) {
        String pkgname=parser.getAttributeValue(null,"String_Node_Str");
        if (pkgname == null) {
          Slog.w(TAG,"String_Node_Str" + permFile + "String_Node_Str"+ parser.getPositionDescription());
        }
 else {
          mSystemUserBlacklistedApps.add(pkgname);
        }
        XmlUtils.skipCurrentTag(parser);
      }
 else {
        XmlUtils.skipCurrentTag(parser);
        continue;
      }
    }
  }
 catch (  XmlPullParserException e) {
    Slog.w(TAG,"String_Node_Str",e);
  }
catch (  IOException e) {
    Slog.w(TAG,"String_Node_Str",e);
  }
 finally {
    IoUtils.closeQuietly(permReader);
  }
  if (StorageManager.isNativeFileBasedEncryptionEnabled()) {
    addFeature(PackageManager.FEATURE_FILE_BASED_ENCRYPTION,0);
    addFeature(PackageManager.FEATURE_SECURELY_REMOVES_USERS,0);
  }
  for (  String featureName : mUnavailableFeatures) {
    removeFeature(featureName);
  }
}

Fixed version (ground truth):
private void readPermissionsFromXml(File permFile,int permissionFlag){
  FileReader permReader=null;
  try {
    permReader=new FileReader(permFile);
  }
 catch (  FileNotFoundException e) {
    Slog.w(TAG,"String_Node_Str" + permFile);
    return;
  }
  final boolean lowRam=ActivityManager.isLowRamDeviceStatic();
  try {
    XmlPullParser parser=Xml.newPullParser();
    parser.setInput(permReader);
    int type;
    while ((type=parser.next()) != parser.START_TAG && type != parser.END_DOCUMENT) {
      ;
    }
    if (type != parser.START_TAG) {
      throw new XmlPullParserException("String_Node_Str");
    }
    if (!parser.getName().equals("String_Node_Str") && !parser.getName().equals("String_Node_Str")) {
      throw new XmlPullParserException("String_Node_Str" + permFile + "String_Node_Str"+ parser.getName()+ "String_Node_Str");
    }
    boolean allowAll=permissionFlag == ALLOW_ALL;
    boolean allowLibs=(permissionFlag & ALLOW_LIBS) != 0;
    boolean allowFeatures=(permissionFlag & ALLOW_FEATURES) != 0;
    boolean allowPermissions=(permissionFlag & ALLOW_PERMISSIONS) != 0;
    boolean allowAppConfigs=(permissionFlag & ALLOW_APP_CONFIGS) != 0;
    while (true) {
      XmlUtils.nextElement(parser);
      if (parser.getEventType() == XmlPullParser.END_DOCUMENT) {
        break;
      }
      String name=parser.getName();
      if ("String_Node_Str".equals(name) && allowAll) {
        String gidStr=parser.getAttributeValue(null,"String_Node_Str");
        if (gidStr != null) {
          int gid=android.os.Process.getGidForName(gidStr);
          mGlobalGids=appendInt(mGlobalGids,gid);
        }
 else {
          Slog.w(TAG,"String_Node_Str" + permFile + "String_Node_Str"+ parser.getPositionDescription());
        }
        XmlUtils.skipCurrentTag(parser);
        continue;
      }
 else       if ("String_Node_Str".equals(name) && allowPermissions) {
        String perm=parser.getAttributeValue(null,"String_Node_Str");
        if (perm == null) {
          Slog.w(TAG,"String_Node_Str" + permFile + "String_Node_Str"+ parser.getPositionDescription());
          XmlUtils.skipCurrentTag(parser);
          continue;
        }
        perm=perm.intern();
        readPermission(parser,perm);
      }
 else       if ("String_Node_Str".equals(name) && allowPermissions) {
        String perm=parser.getAttributeValue(null,"String_Node_Str");
        if (perm == null) {
          Slog.w(TAG,"String_Node_Str" + permFile + "String_Node_Str"+ parser.getPositionDescription());
          XmlUtils.skipCurrentTag(parser);
          continue;
        }
        String uidStr=parser.getAttributeValue(null,"String_Node_Str");
        if (uidStr == null) {
          Slog.w(TAG,"String_Node_Str" + permFile + "String_Node_Str"+ parser.getPositionDescription());
          XmlUtils.skipCurrentTag(parser);
          continue;
        }
        int uid=Process.getUidForName(uidStr);
        if (uid < 0) {
          Slog.w(TAG,"String_Node_Str" + uidStr + "String_Node_Str"+ permFile+ "String_Node_Str"+ parser.getPositionDescription());
          XmlUtils.skipCurrentTag(parser);
          continue;
        }
        perm=perm.intern();
        ArraySet<String> perms=mSystemPermissions.get(uid);
        if (perms == null) {
          perms=new ArraySet<String>();
          mSystemPermissions.put(uid,perms);
        }
        perms.add(perm);
        XmlUtils.skipCurrentTag(parser);
      }
 else       if ("String_Node_Str".equals(name) && allowLibs) {
        String lname=parser.getAttributeValue(null,"String_Node_Str");
        String lfile=parser.getAttributeValue(null,"String_Node_Str");
        if (lname == null) {
          Slog.w(TAG,"String_Node_Str" + permFile + "String_Node_Str"+ parser.getPositionDescription());
        }
 else         if (lfile == null) {
          Slog.w(TAG,"String_Node_Str" + permFile + "String_Node_Str"+ parser.getPositionDescription());
        }
 else {
          mSharedLibraries.put(lname,lfile);
        }
        XmlUtils.skipCurrentTag(parser);
        continue;
      }
 else       if ("String_Node_Str".equals(name) && allowFeatures) {
        String fname=parser.getAttributeValue(null,"String_Node_Str");
        int fversion=XmlUtils.readIntAttribute(parser,"String_Node_Str",0);
        boolean allowed;
        if (!lowRam) {
          allowed=true;
        }
 else {
          String notLowRam=parser.getAttributeValue(null,"String_Node_Str");
          allowed=!"String_Node_Str".equals(notLowRam);
        }
        if (fname == null) {
          Slog.w(TAG,"String_Node_Str" + permFile + "String_Node_Str"+ parser.getPositionDescription());
        }
 else         if (allowed) {
          addFeature(fname,fversion);
        }
        XmlUtils.skipCurrentTag(parser);
        continue;
      }
 else       if ("String_Node_Str".equals(name) && allowFeatures) {
        String fname=parser.getAttributeValue(null,"String_Node_Str");
        if (fname == null) {
          Slog.w(TAG,"String_Node_Str" + permFile + "String_Node_Str"+ parser.getPositionDescription());
        }
 else {
          mUnavailableFeatures.add(fname);
        }
        XmlUtils.skipCurrentTag(parser);
        continue;
      }
 else       if ("String_Node_Str".equals(name) && allowAll) {
        String pkgname=parser.getAttributeValue(null,"String_Node_Str");
        if (pkgname == null) {
          Slog.w(TAG,"String_Node_Str" + permFile + "String_Node_Str"+ parser.getPositionDescription());
        }
 else {
          mAllowInPowerSaveExceptIdle.add(pkgname);
        }
        XmlUtils.skipCurrentTag(parser);
        continue;
      }
 else       if ("String_Node_Str".equals(name) && allowAll) {
        String pkgname=parser.getAttributeValue(null,"String_Node_Str");
        if (pkgname == null) {
          Slog.w(TAG,"String_Node_Str" + permFile + "String_Node_Str"+ parser.getPositionDescription());
        }
 else {
          mAllowInPowerSave.add(pkgname);
        }
        XmlUtils.skipCurrentTag(parser);
        continue;
      }
 else       if ("String_Node_Str".equals(name) && allowAll) {
        String pkgname=parser.getAttributeValue(null,"String_Node_Str");
        if (pkgname == null) {
          Slog.w(TAG,"String_Node_Str" + permFile + "String_Node_Str"+ parser.getPositionDescription());
        }
 else {
          mFixedImeApps.add(pkgname);
        }
        XmlUtils.skipCurrentTag(parser);
        continue;
      }
 else       if ("String_Node_Str".equals(name) && allowAppConfigs) {
        String pkgname=parser.getAttributeValue(null,"String_Node_Str");
        if (pkgname == null) {
          Slog.w(TAG,"String_Node_Str" + permFile + "String_Node_Str"+ parser.getPositionDescription());
        }
 else {
          mLinkedApps.add(pkgname);
        }
        XmlUtils.skipCurrentTag(parser);
      }
 else       if ("String_Node_Str".equals(name) && allowAppConfigs) {
        String pkgname=parser.getAttributeValue(null,"String_Node_Str");
        if (pkgname == null) {
          Slog.w(TAG,"String_Node_Str" + permFile + "String_Node_Str"+ parser.getPositionDescription());
        }
 else {
          mSystemUserWhitelistedApps.add(pkgname);
        }
        XmlUtils.skipCurrentTag(parser);
      }
 else       if ("String_Node_Str".equals(name) && allowAppConfigs) {
        String pkgname=parser.getAttributeValue(null,"String_Node_Str");
        if (pkgname == null) {
          Slog.w(TAG,"String_Node_Str" + permFile + "String_Node_Str"+ parser.getPositionDescription());
        }
 else {
          mSystemUserBlacklistedApps.add(pkgname);
        }
        XmlUtils.skipCurrentTag(parser);
      }
 else {
        XmlUtils.skipCurrentTag(parser);
        continue;
      }
    }
  }
 catch (  XmlPullParserException e) {
    Slog.w(TAG,"String_Node_Str",e);
  }
catch (  IOException e) {
    Slog.w(TAG,"String_Node_Str",e);
  }
 finally {
    IoUtils.closeQuietly(permReader);
  }
  if (StorageManager.isNativeFileBasedEncryptionEnabled()) {
    addFeature(PackageManager.FEATURE_FILE_BASED_ENCRYPTION,0);
    addFeature(PackageManager.FEATURE_SECURELY_REMOVES_USERS,0);
  }
  for (  String featureName : mUnavailableFeatures) {
    removeFeature(featureName);
  }
}