Program: 85947
Project: 85947
Buggy source:
/** 
 * Throws an exception if the blocks difficulty is not correct.
 */
private void checkDifficultyTransitions(StoredBlock storedPrev,StoredBlock storedNext) throws BlockStoreException, VerificationException {
  Block prev=storedPrev.getHeader();
  Block next=storedNext.getHeader();
  if ((storedPrev.getHeight() + 1) % params.interval != 0) {
    if (next.getDifficultyTarget() != prev.getDifficultyTarget())     throw new VerificationException("String_Node_Str" + storedPrev.getHeight() + "String_Node_Str"+ Long.toHexString(next.getDifficultyTarget())+ "String_Node_Str"+ Long.toHexString(prev.getDifficultyTarget()));
    return;
  }
  long now=System.currentTimeMillis();
  StoredBlock cursor=blockStore.get(prev.getHash());
  for (int i=0; i < params.interval - 1; i++) {
    if (cursor == null) {
      throw new VerificationException("String_Node_Str");
    }
    cursor=blockStore.get(cursor.getHeader().getPrevBlockHash());
  }
  log.debug("String_Node_Str",System.currentTimeMillis() - now);
  Block blockIntervalAgo=cursor.getHeader();
  int timespan=(int)(prev.getTimeSeconds() - blockIntervalAgo.getTimeSeconds());
  if (timespan < params.targetTimespan / 4)   timespan=params.targetTimespan / 4;
  if (timespan > params.targetTimespan * 4)   timespan=params.targetTimespan * 4;
  BigInteger newDifficulty=Utils.decodeCompactBits(blockIntervalAgo.getDifficultyTarget());
  newDifficulty=newDifficulty.multiply(BigInteger.valueOf(timespan));
  newDifficulty=newDifficulty.divide(BigInteger.valueOf(params.targetTimespan));
  if (newDifficulty.compareTo(params.proofOfWorkLimit) > 0) {
    log.debug("String_Node_Str",newDifficulty.toString(16));
    newDifficulty=params.proofOfWorkLimit;
  }
  int accuracyBytes=(int)(next.getDifficultyTarget() >>> 24) - 3;
  BigInteger receivedDifficulty=next.getDifficultyTargetAsInteger();
  BigInteger mask=BigInteger.valueOf(0xFFFFFFL).shiftLeft(accuracyBytes * 8);
  newDifficulty=newDifficulty.and(mask);
  if (newDifficulty.compareTo(receivedDifficulty) != 0)   throw new VerificationException("String_Node_Str" + receivedDifficulty.toString(16) + "String_Node_Str"+ newDifficulty.toString(16));
}

Fixed version (ground truth):
/** 
 * Throws an exception if the blocks difficulty is not correct.
 */
private void checkDifficultyTransitions(StoredBlock storedPrev,StoredBlock storedNext) throws BlockStoreException, VerificationException {
  Block prev=storedPrev.getHeader();
  Block next=storedNext.getHeader();
  if ((storedPrev.getHeight() + 1) % params.interval != 0) {
    if (params.getId().equals(NetworkParameters.ID_TESTNET) && next.getTime().after(testnetDiffDate)) {
      checkTestnetDifficulty(storedPrev,prev,next);
      return;
    }
    if (next.getDifficultyTarget() != prev.getDifficultyTarget())     throw new VerificationException("String_Node_Str" + storedPrev.getHeight() + "String_Node_Str"+ Long.toHexString(next.getDifficultyTarget())+ "String_Node_Str"+ Long.toHexString(prev.getDifficultyTarget()));
    return;
  }
  long now=System.currentTimeMillis();
  StoredBlock cursor=blockStore.get(prev.getHash());
  for (int i=0; i < params.interval - 1; i++) {
    if (cursor == null) {
      throw new VerificationException("String_Node_Str");
    }
    cursor=blockStore.get(cursor.getHeader().getPrevBlockHash());
  }
  log.info("String_Node_Str",System.currentTimeMillis() - now);
  Block blockIntervalAgo=cursor.getHeader();
  int timespan=(int)(prev.getTimeSeconds() - blockIntervalAgo.getTimeSeconds());
  if (timespan < params.targetTimespan / 4)   timespan=params.targetTimespan / 4;
  if (timespan > params.targetTimespan * 4)   timespan=params.targetTimespan * 4;
  BigInteger newDifficulty=Utils.decodeCompactBits(blockIntervalAgo.getDifficultyTarget());
  newDifficulty=newDifficulty.multiply(BigInteger.valueOf(timespan));
  newDifficulty=newDifficulty.divide(BigInteger.valueOf(params.targetTimespan));
  if (newDifficulty.compareTo(params.proofOfWorkLimit) > 0) {
    log.info("String_Node_Str",newDifficulty.toString(16));
    newDifficulty=params.proofOfWorkLimit;
  }
  int accuracyBytes=(int)(next.getDifficultyTarget() >>> 24) - 3;
  BigInteger receivedDifficulty=next.getDifficultyTargetAsInteger();
  BigInteger mask=BigInteger.valueOf(0xFFFFFFL).shiftLeft(accuracyBytes * 8);
  newDifficulty=newDifficulty.and(mask);
  if (newDifficulty.compareTo(receivedDifficulty) != 0)   throw new VerificationException("String_Node_Str" + receivedDifficulty.toString(16) + "String_Node_Str"+ newDifficulty.toString(16));
}