Program: 52455
Project: 52455
Buggy source:
/** 
 * Validate the timestamp request, checking the digest to see if it is of an accepted type and whether it is of the correct length for the algorithm specified.
 * @param algorithms a set of OIDs giving accepted algorithms.
 * @param policies if non-null a set of policies OIDs we are willing to sign under.
 * @param extensions if non-null a set of extensions OIDs we are willing to accept.
 * @throws TSPException if the request is invalid, or processing fails.
 */
public void validate(Set algorithms,Set policies,Set extensions) throws TSPException {
  algorithms=convert(algorithms);
  policies=convert(policies);
  extensions=convert(extensions);
  if (!algorithms.contains(this.getMessageImprintAlgOID())) {
    throw new TSPValidationException("String_Node_Str",PKIFailureInfo.badAlg);
  }
  if (policies != null && this.getReqPolicy() != null && !policies.contains(this.getReqPolicy())) {
    throw new TSPValidationException("String_Node_Str",PKIFailureInfo.unacceptedPolicy);
  }
  if (this.getExtensions() != null && extensions != null) {
    Enumeration en=this.getExtensions().oids();
    while (en.hasMoreElements()) {
      String oid=((ASN1ObjectIdentifier)en.nextElement()).getId();
      if (!extensions.contains(oid)) {
        throw new TSPValidationException("String_Node_Str",PKIFailureInfo.unacceptedExtension);
      }
    }
  }
  int digestLength=TSPUtil.getDigestLength(this.getMessageImprintAlgOID().getId());
  if (digestLength != this.getMessageImprintDigest().length) {
    throw new TSPValidationException("String_Node_Str",PKIFailureInfo.badDataFormat);
  }
}

Fixed version (ground truth):
/** 
 * Validate the timestamp request, checking the digest to see if it is of an accepted type and whether it is of the correct length for the algorithm specified.
 * @param algorithms a set of OIDs giving accepted algorithms.
 * @param policies if non-null a set of policies OIDs we are willing to sign under.
 * @param extensions if non-null a set of extensions OIDs we are willing to accept.
 * @throws TSPException if the request is invalid, or processing fails.
 */
public void validate(Set algorithms,Set policies,Set extensions) throws TSPException {
  algorithms=convert(algorithms);
  policies=convert(policies);
  extensions=convert(extensions);
  if (!algorithms.contains(this.getMessageImprintAlgOID())) {
    throw new TSPValidationException("String_Node_Str",PKIFailureInfo.badAlg);
  }
  if (policies != null && this.getReqPolicy() != null && !policies.contains(this.getReqPolicy())) {
    throw new TSPValidationException("String_Node_Str",PKIFailureInfo.unacceptedPolicy);
  }
  if (this.getExtensions() != null && extensions != null) {
    Enumeration en=this.getExtensions().oids();
    while (en.hasMoreElements()) {
      ASN1ObjectIdentifier oid=(ASN1ObjectIdentifier)en.nextElement();
      if (!extensions.contains(oid)) {
        throw new TSPValidationException("String_Node_Str",PKIFailureInfo.unacceptedExtension);
      }
    }
  }
  int digestLength=TSPUtil.getDigestLength(this.getMessageImprintAlgOID().getId());
  if (digestLength != this.getMessageImprintDigest().length) {
    throw new TSPValidationException("String_Node_Str",PKIFailureInfo.badDataFormat);
  }
}