Program: 154339
Project: 154339
Buggy source:
public ServerCertificate(byte[] certificate){
  String cert=new String(certificate,TLSEngine.ENCODING);
  int serialNumberStart=cert.indexOf(SERIAL_NUMBER_INFO) + SERIAL_NUMBER_INFO.length();
  int serialNumberEnd=cert.indexOf(NL,serialNumberStart);
  try {
    serialNumber=Integer.parseInt(cert.substring(serialNumberStart,serialNumberEnd));
  }
 catch (  NumberFormatException nfe) {
    serialNumber=-1;
  }
  int subjectStart=cert.indexOf(SUBJECT_INFO) + SUBJECT_INFO.length();
  int subjectEnd=cert.indexOf(NL,subjectStart);
  subject=cert.substring(subjectStart,subjectEnd);
  int notValidBeforeStart=cert.indexOf(VALID_NOT_BEFORE_INFO) + VALID_NOT_BEFORE_INFO.length();
  int notValidBeforeEnd=cert.indexOf(NL,notValidBeforeStart);
  int notValidAfterStart=cert.indexOf(VALID_NOT_AFTER_INFO) + VALID_NOT_AFTER_INFO.length();
  int notValidAfterEnd=cert.indexOf(NL,notValidAfterStart);
  calendar=new GregorianCalendar();
  SimpleDateFormat sdf=new SimpleDateFormat("String_Node_Str",Locale.US);
  try {
    notValidBefore=sdf.parse(cert.substring(notValidBeforeStart,notValidBeforeEnd));
    notValidAfter=sdf.parse(cert.substring(notValidAfterStart,notValidAfterEnd));
  }
 catch (  ParseException e) {
    notValidBefore=calendar.getTime();
    notValidAfter=calendar.getTime();
  }
  int keyAlgorithmStart=cert.indexOf(PUBLIC_KEY_ALG_INFO) + PUBLIC_KEY_ALG_INFO.length();
  int keyAlgorithmEnd=cert.indexOf(NL,keyAlgorithmStart);
  String keyInf=cert.substring(keyAlgorithmStart,keyAlgorithmEnd);
  int keyBitLengthStart=cert.indexOf(PUBLIC_KEY_INFO) + PUBLIC_KEY_INFO.length();
  keyBitLengthStart=cert.indexOf("String_Node_Str",keyBitLengthStart);
  int publicKeyModulusStart=cert.indexOf(MODULUS_INFO) + MODULUS_INFO.length();
  publicKeyModulusStart=cert.indexOf(NL,publicKeyModulusStart) + 2;
  int publicKeyModulusEnd=cert.indexOf(NL,publicKeyModulusStart);
  String publicModulusKey=cert.substring(publicKeyModulusStart,publicKeyModulusEnd);
  int publicExponentKeyStart=cert.indexOf(EXPONENT_INFO) + EXPONENT_INFO.length();
  int publicExponentKeyEnd=cert.indexOf(NL,publicExponentKeyStart);
  String publicExponentKey=cert.substring(publicExponentKeyStart,publicExponentKeyEnd);
  BigInteger intPublicKeyModulus, intPublicExponentKey;
  try {
    intPublicKeyModulus=new BigInteger(publicModulusKey);
    intPublicExponentKey=new BigInteger(publicExponentKey);
  }
 catch (  Exception e) {
    intPublicKeyModulus=BigInteger.ZERO;
    intPublicExponentKey=BigInteger.ZERO;
  }
  if (keyInf.equals(crypto.keyexchange.DH.ALGORITHM_NAME))   key=new crypto.keyexchange.DH(intPublicKeyModulus,intPublicExponentKey);
 else   if (keyInf.equals(crypto.keyexchange.RSA.ALGORITHM_NAME))   key=new crypto.keyexchange.RSA(intPublicKeyModulus,intPublicExponentKey);
 else   key=new crypto.keyexchange.None();
}

Fixed version (ground truth):
public ServerCertificate(byte[] certificate){
  String cert=new String(certificate,TLSEngine.ENCODING);
  int serialNumberStart=cert.indexOf(SERIAL_NUMBER_INFO) + SERIAL_NUMBER_INFO.length();
  int serialNumberEnd=cert.indexOf(NL,serialNumberStart);
  try {
    serialNumber=Integer.parseInt(cert.substring(serialNumberStart,serialNumberEnd));
  }
 catch (  Exception nfe) {
    Tools.print("String_Node_Str" + serialNumberStart + "String_Node_Str"+ serialNumberEnd);
    serialNumber=-1;
  }
  int subjectStart=cert.indexOf(SUBJECT_INFO) + SUBJECT_INFO.length();
  int subjectEnd=cert.indexOf(NL,subjectStart);
  subject=cert.substring(subjectStart,subjectEnd);
  int notValidBeforeStart=cert.indexOf(VALID_NOT_BEFORE_INFO) + VALID_NOT_BEFORE_INFO.length();
  int notValidBeforeEnd=cert.indexOf(NL,notValidBeforeStart);
  int notValidAfterStart=cert.indexOf(VALID_NOT_AFTER_INFO) + VALID_NOT_AFTER_INFO.length();
  int notValidAfterEnd=cert.indexOf(NL,notValidAfterStart);
  calendar=new GregorianCalendar();
  SimpleDateFormat sdf=new SimpleDateFormat("String_Node_Str",Locale.US);
  try {
    notValidBefore=sdf.parse(cert.substring(notValidBeforeStart,notValidBeforeEnd));
    notValidAfter=sdf.parse(cert.substring(notValidAfterStart,notValidAfterEnd));
  }
 catch (  ParseException e) {
    notValidBefore=calendar.getTime();
    notValidAfter=calendar.getTime();
  }
  int keyAlgorithmStart=cert.indexOf(PUBLIC_KEY_ALG_INFO) + PUBLIC_KEY_ALG_INFO.length();
  int keyAlgorithmEnd=cert.indexOf(NL,keyAlgorithmStart);
  String keyInf=cert.substring(keyAlgorithmStart,keyAlgorithmEnd);
  int keyBitLengthStart=cert.indexOf(PUBLIC_KEY_INFO) + PUBLIC_KEY_INFO.length();
  keyBitLengthStart=cert.indexOf("String_Node_Str",keyBitLengthStart);
  int publicKeyModulusStart=cert.indexOf(MODULUS_INFO) + MODULUS_INFO.length();
  publicKeyModulusStart=cert.indexOf(NL,publicKeyModulusStart) + 2;
  int publicKeyModulusEnd=cert.indexOf(NL,publicKeyModulusStart);
  String publicModulusKey=cert.substring(publicKeyModulusStart,publicKeyModulusEnd);
  int publicExponentKeyStart=cert.indexOf(EXPONENT_INFO) + EXPONENT_INFO.length();
  int publicExponentKeyEnd=cert.indexOf(NL,publicExponentKeyStart);
  String publicExponentKey=cert.substring(publicExponentKeyStart,publicExponentKeyEnd);
  BigInteger intPublicKeyModulus, intPublicExponentKey;
  try {
    intPublicKeyModulus=new BigInteger(publicModulusKey);
    intPublicExponentKey=new BigInteger(publicExponentKey);
  }
 catch (  Exception e) {
    intPublicKeyModulus=BigInteger.ZERO;
    intPublicExponentKey=BigInteger.ZERO;
  }
  if (keyInf.equals(crypto.keyexchange.DH.ALGORITHM_NAME))   key=new crypto.keyexchange.DH(intPublicKeyModulus,intPublicExponentKey);
 else   if (keyInf.equals(crypto.keyexchange.RSA.ALGORITHM_NAME))   key=new crypto.keyexchange.RSA(intPublicKeyModulus,intPublicExponentKey);
 else   key=new crypto.keyexchange.None();
}