Program: 8417
Project: 8417
Buggy source:
public static Bundle importKeyRings(Context context,int type,InputData data,ProgressDialogUpdater progress) throws GeneralException, FileNotFoundException, PGPException, IOException {
  Bundle returnData=new Bundle();
  if (type == Id.type.secret_key) {
    if (progress != null)     progress.setProgress(R.string.progress_importingSecretKeys,0,100);
  }
 else {
    if (progress != null)     progress.setProgress(R.string.progress_importingPublicKeys,0,100);
  }
  if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
    throw new GeneralException(context.getString(R.string.error_externalStorageNotReady));
  }
  PositionAwareInputStream progressIn=new PositionAwareInputStream(data.getInputStream());
  BufferedInputStream bufferedInput=new BufferedInputStream(progressIn);
  int newKeys=0;
  int oldKeys=0;
  int badKeys=0;
  try {
    PGPKeyRing keyring=PGPHelper.decodeKeyRing(bufferedInput);
    while (keyring != null) {
      int status=Integer.MIN_VALUE;
      if ((type == Id.type.secret_key && keyring instanceof PGPSecretKeyRing) || (type == Id.type.public_key && keyring instanceof PGPPublicKeyRing)) {
        status=storeKeyRingInCache(keyring);
      }
      if (status == Id.return_value.error) {
        throw new GeneralException(context.getString(R.string.error_savingKeys));
      }
      if (status == Id.return_value.updated) {
        ++oldKeys;
      }
 else       if (status == Id.return_value.ok) {
        ++newKeys;
      }
 else       if (status == Id.return_value.bad) {
        ++badKeys;
      }
      if (progress != null) {
        progress.setProgress((int)(100 * progressIn.position() / data.getSize()),100);
      }
      keyring=PGPHelper.decodeKeyRing(bufferedInput);
    }
  }
 catch (  EOFException e) {
  }
  returnData.putInt(ApgService.RESULT_IMPORT_ADDED,newKeys);
  returnData.putInt(ApgService.RESULT_IMPORT_UPDATED,oldKeys);
  returnData.putInt(ApgService.RESULT_IMPORT_BAD,badKeys);
  if (progress != null)   progress.setProgress(R.string.progress_done,100,100);
  return returnData;
}

Fixed version (ground truth):
public static Bundle importKeyRings(Context context,int type,InputData data,ProgressDialogUpdater progress) throws GeneralException, FileNotFoundException, PGPException, IOException {
  Bundle returnData=new Bundle();
  if (type == Id.type.secret_key) {
    if (progress != null)     progress.setProgress(R.string.progress_importingSecretKeys,0,100);
  }
 else {
    if (progress != null)     progress.setProgress(R.string.progress_importingPublicKeys,0,100);
  }
  if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
    throw new GeneralException(context.getString(R.string.error_externalStorageNotReady));
  }
  PositionAwareInputStream progressIn=new PositionAwareInputStream(data.getInputStream());
  BufferedInputStream bufferedInput=new BufferedInputStream(progressIn);
  int newKeys=0;
  int oldKeys=0;
  int badKeys=0;
  try {
    PGPKeyRing keyring=PGPHelper.decodeKeyRing(bufferedInput);
    while (keyring != null) {
      int status=Integer.MIN_VALUE;
      if ((type == Id.type.secret_key && keyring instanceof PGPSecretKeyRing) || (type == Id.type.public_key && keyring instanceof PGPPublicKeyRing)) {
        status=storeKeyRingInCache(keyring);
      }
      if (status == Id.return_value.error) {
        throw new GeneralException(context.getString(R.string.error_savingKeys));
      }
      if (status == Id.return_value.updated) {
        ++oldKeys;
      }
 else       if (status == Id.return_value.ok) {
        ++newKeys;
      }
 else       if (status == Id.return_value.bad) {
        ++badKeys;
      }
      updateProgress(progress,(int)(100 * progressIn.position() / data.getSize()),100);
      keyring=PGPHelper.decodeKeyRing(bufferedInput);
    }
  }
 catch (  EOFException e) {
  }
  returnData.putInt(ApgService.RESULT_IMPORT_ADDED,newKeys);
  returnData.putInt(ApgService.RESULT_IMPORT_UPDATED,oldKeys);
  returnData.putInt(ApgService.RESULT_IMPORT_BAD,badKeys);
  updateProgress(progress,R.string.progress_done,100,100);
  return returnData;
}