Program: 80665
Project: 80665
Buggy source:
/** 
 * Decrypt, verify and write input stream data to output stream. Input and output streams are closed.
 */
private static DecryptionResult decryptAndVerify(InputStream encryptedInput,OutputStream plainOutput,PersonalKey myKey,PGPPublicKey senderSigningKey){
  DecryptionResult result=new DecryptionResult();
  PGPObjectFactory pgpFactory=new PGPObjectFactory(encryptedInput,PGPUtils.FP_CALC);
  try {
    Object o=pgpFactory.nextObject();
    if (!(o instanceof PGPEncryptedDataList)) {
      o=pgpFactory.nextObject();
    }
    if (!(o instanceof PGPEncryptedDataList)) {
      LOGGER.warning("String_Node_Str");
      result.errors.add(Error.INVALID_DATA);
      return result;
    }
    PGPEncryptedDataList encDataList=(PGPEncryptedDataList)o;
    Iterator<?> it=encDataList.getEncryptedDataObjects();
    PGPPrivateKey sKey=null;
    PGPPublicKeyEncryptedData pbe=null;
    long myKeyID=myKey.getPrivateEncryptionKey().getKeyID();
    while (sKey == null && it.hasNext()) {
      Object i=it.next();
      if (!(i instanceof PGPPublicKeyEncryptedData))       continue;
      pbe=(PGPPublicKeyEncryptedData)i;
      if (pbe.getKeyID() == myKeyID)       sKey=myKey.getPrivateEncryptionKey();
    }
    if (sKey == null || pbe == null) {
      LOGGER.warning("String_Node_Str");
      result.errors.add(Error.INVALID_PRIVATE_KEY);
      return result;
    }
    InputStream clear=pbe.getDataStream(new BcPublicKeyDataDecryptorFactory(sKey));
    PGPObjectFactory plainFactory=new PGPObjectFactory(clear,PGPUtils.FP_CALC);
    Object object=plainFactory.nextObject();
    if (!(object instanceof PGPCompressedData)) {
      LOGGER.warning("String_Node_Str");
      result.errors.add(Error.INVALID_DATA);
      return result;
    }
    PGPCompressedData cData=(PGPCompressedData)object;
    PGPObjectFactory pgpFact=new PGPObjectFactory(cData.getDataStream(),PGPUtils.FP_CALC);
    object=pgpFact.nextObject();
    PGPOnePassSignature ops=null;
    if (object instanceof PGPOnePassSignatureList) {
      PGPOnePassSignatureList signatureList=(PGPOnePassSignatureList)object;
      result.signing=Signing.SIGNED;
      if (signatureList.isEmpty()) {
        LOGGER.warning("String_Node_Str");
        result.errors.add(Error.INVALID_SIGNATURE_DATA);
      }
 else {
        ops=signatureList.get(0);
        try {
          ops.init(new BcPGPContentVerifierBuilderProvider(),senderSigningKey);
        }
 catch (        ClassCastException e) {
          LOGGER.warning("String_Node_Str");
          result.errors.add(Error.INVALID_SIGNATURE_DATA);
          ops=null;
        }
      }
      object=pgpFact.nextObject();
    }
 else {
      LOGGER.warning("String_Node_Str");
      result.signing=Signing.NOT;
    }
    if (!(object instanceof PGPLiteralData)) {
      LOGGER.warning("String_Node_Str" + object.getClass().getName());
      result.errors.add(Error.INVALID_DATA);
      return result;
    }
    PGPLiteralData ld=(PGPLiteralData)object;
    InputStream unc=ld.getInputStream();
    int ch;
    while ((ch=unc.read()) >= 0) {
      plainOutput.write(ch);
      if (ops != null)       ops.update((byte)ch);
    }
    plainOutput.close();
    encryptedInput.close();
    result.decrypted=true;
    if (ops != null) {
      result=verifySignature(result,pgpFact,ops);
    }
    if (pbe.isIntegrityProtected()) {
      if (!pbe.verify()) {
        LOGGER.warning("String_Node_Str");
        result.errors.add(Error.INVALID_INTEGRITY);
      }
    }
 else {
      LOGGER.warning("String_Node_Str");
      result.errors.add(Error.NO_INTEGRITY);
    }
  }
 catch (  IOException|PGPException ex) {
    LOGGER.log(Level.WARNING,"String_Node_Str",ex);
    result.errors.add(Error.UNKNOWN_ERROR);
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Decrypt, verify and write input stream data to output stream. Input and output streams are closed.
 */
private static DecryptionResult decryptAndVerify(InputStream encryptedInput,OutputStream plainOutput,PersonalKey myKey,PGPPublicKey senderSigningKey){
  DecryptionResult result=new DecryptionResult();
  PGPObjectFactory pgpFactory=new PGPObjectFactory(encryptedInput,PGPUtils.FP_CALC);
  try {
    Object o=pgpFactory.nextObject();
    if (!(o instanceof PGPEncryptedDataList)) {
      o=pgpFactory.nextObject();
    }
    if (!(o instanceof PGPEncryptedDataList)) {
      LOGGER.warning("String_Node_Str");
      result.errors.add(Error.INVALID_DATA);
      return result;
    }
    PGPEncryptedDataList encDataList=(PGPEncryptedDataList)o;
    Iterator<?> it=encDataList.getEncryptedDataObjects();
    PGPPrivateKey sKey=null;
    PGPPublicKeyEncryptedData pbe=null;
    long myKeyID=myKey.getPrivateEncryptionKey().getKeyID();
    while (sKey == null && it.hasNext()) {
      Object i=it.next();
      if (!(i instanceof PGPPublicKeyEncryptedData))       continue;
      pbe=(PGPPublicKeyEncryptedData)i;
      if (pbe.getKeyID() == myKeyID)       sKey=myKey.getPrivateEncryptionKey();
    }
    if (sKey == null || pbe == null) {
      LOGGER.warning("String_Node_Str");
      result.errors.add(Error.INVALID_PRIVATE_KEY);
      return result;
    }
    InputStream clear=pbe.getDataStream(new BcPublicKeyDataDecryptorFactory(sKey));
    PGPObjectFactory plainFactory=new PGPObjectFactory(clear,PGPUtils.FP_CALC);
    Object object=plainFactory.nextObject();
    if (!(object instanceof PGPCompressedData)) {
      LOGGER.warning("String_Node_Str");
      result.errors.add(Error.INVALID_DATA);
      return result;
    }
    PGPCompressedData cData=(PGPCompressedData)object;
    PGPObjectFactory pgpFact=new PGPObjectFactory(cData.getDataStream(),PGPUtils.FP_CALC);
    object=pgpFact.nextObject();
    PGPOnePassSignature ops=null;
    if (object instanceof PGPOnePassSignatureList) {
      PGPOnePassSignatureList signatureList=(PGPOnePassSignatureList)object;
      result.signing=Signing.SIGNED;
      if (signatureList.isEmpty()) {
        LOGGER.warning("String_Node_Str");
        result.errors.add(Error.INVALID_SIGNATURE_DATA);
      }
 else {
        ops=signatureList.get(0);
        try {
          ops.init(new BcPGPContentVerifierBuilderProvider(),senderSigningKey);
        }
 catch (        ClassCastException e) {
          LOGGER.warning("String_Node_Str");
          result.errors.add(Error.INVALID_SIGNATURE_DATA);
          ops=null;
        }
      }
      object=pgpFact.nextObject();
    }
 else {
      LOGGER.warning("String_Node_Str");
      result.signing=Signing.NOT;
    }
    if (!(object instanceof PGPLiteralData)) {
      LOGGER.warning("String_Node_Str" + object.getClass().getName());
      result.errors.add(Error.INVALID_DATA);
      return result;
    }
    PGPLiteralData ld=(PGPLiteralData)object;
    InputStream unc=ld.getInputStream();
    int ch;
    while ((ch=unc.read()) >= 0) {
      plainOutput.write(ch);
      if (ops != null)       ops.update((byte)ch);
    }
    plainOutput.close();
    result.decrypted=true;
    if (ops != null) {
      result=verifySignature(result,pgpFact,ops);
    }
    encryptedInput.close();
    if (pbe.isIntegrityProtected()) {
      if (!pbe.verify()) {
        LOGGER.warning("String_Node_Str");
        result.errors.add(Error.INVALID_INTEGRITY);
      }
    }
 else {
      LOGGER.warning("String_Node_Str");
      result.errors.add(Error.NO_INTEGRITY);
    }
  }
 catch (  IOException|PGPException ex) {
    LOGGER.log(Level.WARNING,"String_Node_Str",ex);
    result.errors.add(Error.UNKNOWN_ERROR);
  }
  return result;
}