Program: 165200
Project: 165200
Buggy source:
/** 
 * Verify that the signing certificate used to sign   {@link #SIGNED_FILE_NAME}matches the signing stored in the database for this repo.    {@link #repo} and{@code repo.signingCertificate} must be pre-loaded from the database beforerunning this, if this is an existing repo.  If the repo does not exist, this will run the TOFU process. <p> Index V1 works with two copies of the signing certificate: <li>in the downloaded jar</li> <li>stored in the local database</li> <p> A new repo can be added with or without the fingerprint of the signing certificate.  If no fingerprint is supplied, then do a pure TOFU and just store the certificate as valid.  If there is a fingerprint, then first check that the signing certificate in the jar matches that fingerprint. <p> This is also responsible for adding the  {@link Repo} instance to thedatabase for the first time. <p> This is the same as  {@link RepoUpdater#verifyCerts(String,X509Certificate)},  {@link RepoUpdater#verifyAndStoreTOFUCerts(String,X509Certificate)}, and  {@link RepoUpdater#assertSigningCertFromXmlCorrect()} except there is noembedded copy of the signing certificate in the index data.
 * @param rawCertFromJar the {@link X509Certificate} embedded in the downloaded jar
 * @see RepoUpdater#verifyAndStoreTOFUCerts(String,X509Certificate)
 * @see RepoUpdater#verifyCerts(String,X509Certificate)
 * @see RepoUpdater#assertSigningCertFromXmlCorrect()
 */
private void verifySigningCertificate(X509Certificate rawCertFromJar) throws SigningException {
  String certFromJar=Hasher.hex(rawCertFromJar);
  if (TextUtils.isEmpty(certFromJar)) {
    throw new SigningException(SIGNED_FILE_NAME + "String_Node_Str");
  }
  if (repo.signingCertificate == null) {
    if (repo.fingerprint != null) {
      String fingerprintFromJar=Utils.calcFingerprint(rawCertFromJar);
      if (!repo.fingerprint.equalsIgnoreCase(fingerprintFromJar)) {
        throw new SigningException("String_Node_Str");
      }
    }
    Utils.debugLog(TAG,"String_Node_Str" + repo.address);
    ContentValues values=new ContentValues(2);
    values.put(Schema.RepoTable.Cols.LAST_UPDATED,Utils.formatDate(new Date(),"String_Node_Str"));
    values.put(Schema.RepoTable.Cols.SIGNING_CERT,Hasher.hex(rawCertFromJar));
    RepoProvider.Helper.update(context,repo,values);
    repo.signingCertificate=certFromJar;
  }
  if (TextUtils.isEmpty(repo.signingCertificate)) {
    throw new SigningException("String_Node_Str");
  }
  if (repo.signingCertificate.equals(certFromJar)) {
    return;
  }
  throw new SigningException("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Verify that the signing certificate used to sign   {@link #SIGNED_FILE_NAME}matches the signing stored in the database for this repo.    {@link #repo} and{@code repo.signingCertificate} must be pre-loaded from the database beforerunning this, if this is an existing repo.  If the repo does not exist, this will run the TOFU process. <p> Index V1 works with two copies of the signing certificate: <li>in the downloaded jar</li> <li>stored in the local database</li> <p> A new repo can be added with or without the fingerprint of the signing certificate.  If no fingerprint is supplied, then do a pure TOFU and just store the certificate as valid.  If there is a fingerprint, then first check that the signing certificate in the jar matches that fingerprint. <p> This is also responsible for adding the  {@link Repo} instance to thedatabase for the first time. <p> This is the same as  {@link RepoUpdater#verifyCerts(String,X509Certificate)},  {@link RepoUpdater#verifyAndStoreTOFUCerts(String,X509Certificate)}, and  {@link RepoUpdater#assertSigningCertFromXmlCorrect()} except there is noembedded copy of the signing certificate in the index data.
 * @param rawCertFromJar the {@link X509Certificate} embedded in the downloaded jar
 * @see RepoUpdater#verifyAndStoreTOFUCerts(String,X509Certificate)
 * @see RepoUpdater#verifyCerts(String,X509Certificate)
 * @see RepoUpdater#assertSigningCertFromXmlCorrect()
 */
private void verifySigningCertificate(X509Certificate rawCertFromJar) throws SigningException {
  String certFromJar=Hasher.hex(rawCertFromJar);
  if (TextUtils.isEmpty(certFromJar)) {
    throw new SigningException(repo,SIGNED_FILE_NAME + "String_Node_Str");
  }
  if (repo.signingCertificate == null) {
    if (repo.fingerprint != null) {
      String fingerprintFromJar=Utils.calcFingerprint(rawCertFromJar);
      if (!repo.fingerprint.equalsIgnoreCase(fingerprintFromJar)) {
        throw new SigningException(repo,"String_Node_Str");
      }
    }
    Utils.debugLog(TAG,"String_Node_Str" + repo.address);
    ContentValues values=new ContentValues(2);
    values.put(Schema.RepoTable.Cols.LAST_UPDATED,Utils.formatDate(new Date(),"String_Node_Str"));
    values.put(Schema.RepoTable.Cols.SIGNING_CERT,Hasher.hex(rawCertFromJar));
    RepoProvider.Helper.update(context,repo,values);
    repo.signingCertificate=certFromJar;
  }
  if (TextUtils.isEmpty(repo.signingCertificate)) {
    throw new SigningException(repo,"String_Node_Str");
  }
  if (repo.signingCertificate.equals(certFromJar)) {
    return;
  }
  throw new SigningException(repo,"String_Node_Str");
}