Program: 187855
Project: 187855
Buggy source:
/** 
 * unencrypt encrypted string previously encrypted with encryptWithSessionKey()
 * @author Peli
 * @param ciphertext
 * @return decrypted String
 * @throws Exception
 */
public Uri decryptFileWithSessionKey(ContentResolver contentResolver,Uri fileUri) throws CryptoHelperException {
  Log.d(TAG,"String_Node_Str");
  status=false;
  if (password == null) {
    String msg="String_Node_Str";
    throw new CryptoHelperException(msg);
  }
  String outputPath="String_Node_Str";
  try {
    InputStream is;
    if (fileUri.getScheme().equals("String_Node_Str")) {
      is=new java.io.FileInputStream(fileUri.getPath());
      String encryptedFile=fileUri.getPath();
      outputPath=fileUri.getPath() + "String_Node_Str";
      if (encryptedFile.endsWith("String_Node_Str")) {
        outputPath=encryptedFile.substring(0,encryptedFile.length() - 7);
      }
      Log.d(TAG,"String_Node_Str" + fileUri.getPath());
      Log.d(TAG,"String_Node_Str" + outputPath);
    }
 else {
      is=contentResolver.openInputStream(fileUri);
      outputPath=Environment.getExternalStorageDirectory().toString() + "String_Node_Str";
    }
    FileOutputStream os=new FileOutputStream(outputPath);
    int numReadTotal=0;
    int numRead=0;
    byte[] byteCipherVersion=new byte[1];
    while ((numRead=is.read(byteCipherVersion,numRead,byteCipherVersion.length - numRead)) >= 0 && numReadTotal < byteCipherVersion.length) {
      Log.d(TAG,"String_Node_Str" + numRead);
      numReadTotal+=numRead;
    }
    String cipherVersion=new String(byteCipherVersion);
    byte[] byteCipherSessionKey=null;
    try {
      Log.d(TAG,"String_Node_Str" + cipherVersion);
      if (cipherVersion.equals("String_Node_Str")) {
        numRead=0;
        numReadTotal=0;
        byteCipherSessionKey=new byte[48];
        while ((numRead=is.read(byteCipherSessionKey,numRead,byteCipherSessionKey.length - numRead)) >= 0 && numReadTotal < byteCipherSessionKey.length) {
          Log.d(TAG,"String_Node_Str" + numRead);
          numReadTotal+=numRead;
        }
      }
 else {
        Log.e(TAG,"String_Node_Str" + cipherVersion);
        return null;
      }
    }
 catch (    IndexOutOfBoundsException e) {
      Log.e(TAG,"String_Node_Str");
      return null;
    }
    byte[] byteSessionKey={};
    try {
      pbeCipher.init(Cipher.DECRYPT_MODE,pbeKey,pbeParamSpec);
      byteSessionKey=pbeCipher.doFinal(byteCipherSessionKey);
      status=true;
    }
 catch (    IllegalBlockSizeException e) {
      Log.e(TAG,"String_Node_Str" + e.toString());
    }
catch (    BadPaddingException e) {
      Log.e(TAG,"String_Node_Str" + e.toString());
    }
catch (    InvalidKeyException e) {
      Log.e(TAG,"String_Node_Str" + e.toString());
    }
catch (    InvalidAlgorithmParameterException e) {
      Log.e(TAG,"String_Node_Str" + e.toString());
    }
    Trivium tri=new Trivium();
    try {
      tri.setupKey(Trivium.MODE_DECRYPT,byteSessionKey,0);
      tri.setupNonce(byteSessionKey,10);
      final int bytesLen=4096;
      byte[] bytesIn=new byte[bytesLen];
      byte[] bytesOut=new byte[bytesLen];
      int offset=0;
      numRead=0;
      while ((numRead=is.read(bytesIn,0,bytesLen)) >= 0) {
        if ((numRead | 3) != 0) {
          Log.d(TAG,"String_Node_Str" + numRead);
        }
        tri.process(bytesIn,0,bytesOut,0,numRead);
        os.write(bytesOut,0,numRead);
        offset+=numRead;
      }
      if (offset < is.available()) {
        throw new IOException("String_Node_Str");
      }
      is.close();
      os.close();
    }
 catch (    ESJException e) {
      Log.e(TAG,"String_Node_Str",e);
    }
  }
 catch (  FileNotFoundException e) {
    Log.e(TAG,"String_Node_Str",e);
  }
catch (  IOException e) {
    Log.e(TAG,"String_Node_Str",e);
  }
  return Uri.parse("String_Node_Str" + outputPath);
}

Fixed version (ground truth):
/** 
 * unencrypt encrypted string previously encrypted with encryptWithSessionKey()
 * @author Peli
 * @param ciphertext
 * @return decrypted String
 * @throws Exception
 */
public Uri decryptFileWithSessionKey(ContentResolver contentResolver,Uri fileUri) throws CryptoHelperException {
  Log.d(TAG,"String_Node_Str");
  status=false;
  if (password == null) {
    String msg="String_Node_Str";
    throw new CryptoHelperException(msg);
  }
  String outputPath="String_Node_Str";
  try {
    InputStream is;
    if (fileUri.getScheme().equals("String_Node_Str")) {
      is=new java.io.FileInputStream(fileUri.getPath());
      String encryptedFile=fileUri.getPath();
      outputPath=fileUri.getPath() + "String_Node_Str";
      if (encryptedFile.endsWith("String_Node_Str")) {
        outputPath=encryptedFile.substring(0,encryptedFile.length() - 7);
      }
      Log.d(TAG,"String_Node_Str" + fileUri.getPath());
      Log.d(TAG,"String_Node_Str" + outputPath);
    }
 else {
      is=contentResolver.openInputStream(fileUri);
      outputPath=Environment.getExternalStorageDirectory().toString() + "String_Node_Str";
    }
    FileOutputStream os=new FileOutputStream(outputPath);
    int numReadTotal=0;
    int numRead=0;
    byte[] byteCipherVersion=new byte[1];
    while ((numRead=is.read(byteCipherVersion,numRead,byteCipherVersion.length - numRead)) >= 0 && numReadTotal < byteCipherVersion.length) {
      Log.d(TAG,"String_Node_Str" + numRead);
      numReadTotal+=numRead;
    }
    String cipherVersion=new String(byteCipherVersion);
    byte[] byteCipherSessionKey=null;
    try {
      Log.d(TAG,"String_Node_Str" + cipherVersion);
      if (cipherVersion.equals("String_Node_Str")) {
        numRead=0;
        numReadTotal=0;
        byteCipherSessionKey=new byte[48];
        while ((numRead=is.read(byteCipherSessionKey,numRead,byteCipherSessionKey.length - numRead)) >= 0 && numReadTotal < byteCipherSessionKey.length) {
          Log.d(TAG,"String_Node_Str" + numRead);
          numReadTotal+=numRead;
        }
      }
 else {
        Log.e(TAG,"String_Node_Str" + cipherVersion);
        return null;
      }
    }
 catch (    IndexOutOfBoundsException e) {
      Log.e(TAG,"String_Node_Str");
      return null;
    }
    byte[] byteSessionKey={};
    try {
      pbeCipher.init(Cipher.DECRYPT_MODE,pbeKey,pbeParamSpec);
      byteSessionKey=pbeCipher.doFinal(byteCipherSessionKey);
      status=true;
    }
 catch (    IllegalBlockSizeException e) {
      Log.e(TAG,"String_Node_Str" + e.toString());
    }
catch (    BadPaddingException e) {
      Log.e(TAG,"String_Node_Str" + e.toString());
    }
catch (    InvalidKeyException e) {
      Log.e(TAG,"String_Node_Str" + e.toString());
    }
catch (    InvalidAlgorithmParameterException e) {
      Log.e(TAG,"String_Node_Str" + e.toString());
    }
    Trivium tri=new Trivium();
    try {
      tri.setupKey(Trivium.MODE_DECRYPT,byteSessionKey,0);
      tri.setupNonce(byteSessionKey,10);
      final int bytesLen=4096;
      byte[] bytesIn=new byte[bytesLen];
      byte[] bytesOut=new byte[bytesLen];
      int offset=0;
      numRead=0;
      while ((numRead=is.read(bytesIn,0,bytesLen)) >= 0) {
        if ((numRead & 3) != 0) {
          Log.d(TAG,"String_Node_Str" + numRead);
        }
        tri.process(bytesIn,0,bytesOut,0,numRead);
        os.write(bytesOut,0,numRead);
        offset+=numRead;
      }
      if (offset < is.available()) {
        throw new IOException("String_Node_Str");
      }
      is.close();
      os.close();
    }
 catch (    ESJException e) {
      Log.e(TAG,"String_Node_Str",e);
    }
  }
 catch (  FileNotFoundException e) {
    Log.e(TAG,"String_Node_Str",e);
  }
catch (  IOException e) {
    Log.e(TAG,"String_Node_Str",e);
  }
  return Uri.parse("String_Node_Str" + outputPath);
}