Program: 52436
Project: 52436
Buggy source:
/** 
 * Validates the signed   {@link MimeMessage} message. The{@link PKIXParameters} from param are used for the certificate pathvalidation. The actual PKIXParameters used for the certificate path validation is a copy of param with the followin changes: <br> - The validation date is changed to the signature time <br> - A CertStore with certificates and crls from the mail message is added to the CertStores.<br> <br> In <code>param</code> it's also possible to add additional CertStores with intermediate Certificates and/or CRLs which then are also used for the validation.
 * @param message               the signed MimeMessage
 * @param param                 the parameters for the certificate path validation
 * @param certPathReviewerClass a subclass of {@link PKIXCertPathReviewer}. The SignedMailValidator uses objects of this type for the cert path vailidation. The class must have an empty constructor.
 * @throws SignedMailValidatorException if the message is no signed message or if an exception occursreading the message
 * @throws IllegalArgumentException if the certPathReviewerClass is not asubclass of  {@link PKIXCertPathReviewer} or objects ofcertPathReviewerClass can not be instantiated
 */
public SignedMailValidator(MimeMessage message,PKIXParameters param,Class certPathReviewerClass) throws SignedMailValidatorException {
  this.certPathReviewerClass=certPathReviewerClass;
  boolean isSubclass=DEFAULT_CERT_PATH_REVIEWER.isAssignableFrom(certPathReviewerClass);
  if (!isSubclass) {
    throw new IllegalArgumentException("String_Node_Str" + DEFAULT_CERT_PATH_REVIEWER.getName());
  }
  SMIMESigned s;
  try {
    if (message.isMimeType("String_Node_Str")) {
      MimeMultipart mimemp=(MimeMultipart)message.getContent();
      s=new SMIMESigned(mimemp);
    }
 else     if (message.isMimeType("String_Node_Str") || message.isMimeType("String_Node_Str")) {
      s=new SMIMESigned(message);
    }
 else {
      ErrorBundle msg=new ErrorBundle(RESOURCE_NAME,"String_Node_Str");
      throw new SignedMailValidatorException(msg);
    }
    certs=new JcaCertStoreBuilder().addCertificates(s.getCertificates()).addCRLs(s.getCRLs()).setProvider("String_Node_Str").build();
    signers=s.getSignerInfos();
    Address[] froms=message.getFrom();
    InternetAddress sender=null;
    try {
      if (message.getHeader("String_Node_Str") != null) {
        sender=new InternetAddress(message.getHeader("String_Node_Str")[0]);
      }
    }
 catch (    MessagingException ex) {
    }
    int fromsLength=(froms != null) ? froms.length : 0;
    fromAddresses=new String[fromsLength + ((sender != null) ? 1 : 0)];
    for (int i=0; i < froms.length; i++) {
      InternetAddress inetAddr=(InternetAddress)froms[i];
      fromAddresses[i]=inetAddr.getAddress();
    }
    if (sender != null) {
      fromAddresses[froms.length]=sender.getAddress();
    }
    results=new HashMap();
  }
 catch (  Exception e) {
    if (e instanceof SignedMailValidatorException) {
      throw (SignedMailValidatorException)e;
    }
    ErrorBundle msg=new ErrorBundle(RESOURCE_NAME,"String_Node_Str",new Object[]{e.getMessage(),e,e.getClass().getName()});
    throw new SignedMailValidatorException(msg,e);
  }
  validateSignatures(param);
}

Fixed version (ground truth):
/** 
 * Validates the signed   {@link MimeMessage} message. The{@link PKIXParameters} from param are used for the certificate pathvalidation. The actual PKIXParameters used for the certificate path validation is a copy of param with the followin changes: <br> - The validation date is changed to the signature time <br> - A CertStore with certificates and crls from the mail message is added to the CertStores.<br> <br> In <code>param</code> it's also possible to add additional CertStores with intermediate Certificates and/or CRLs which then are also used for the validation.
 * @param message               the signed MimeMessage
 * @param param                 the parameters for the certificate path validation
 * @param certPathReviewerClass a subclass of {@link PKIXCertPathReviewer}. The SignedMailValidator uses objects of this type for the cert path vailidation. The class must have an empty constructor.
 * @throws SignedMailValidatorException if the message is no signed message or if an exception occursreading the message
 * @throws IllegalArgumentException if the certPathReviewerClass is not asubclass of  {@link PKIXCertPathReviewer} or objects ofcertPathReviewerClass can not be instantiated
 */
public SignedMailValidator(MimeMessage message,PKIXParameters param,Class certPathReviewerClass) throws SignedMailValidatorException {
  this.certPathReviewerClass=certPathReviewerClass;
  boolean isSubclass=DEFAULT_CERT_PATH_REVIEWER.isAssignableFrom(certPathReviewerClass);
  if (!isSubclass) {
    throw new IllegalArgumentException("String_Node_Str" + DEFAULT_CERT_PATH_REVIEWER.getName());
  }
  SMIMESigned s;
  try {
    if (message.isMimeType("String_Node_Str")) {
      MimeMultipart mimemp=(MimeMultipart)message.getContent();
      s=new SMIMESigned(mimemp);
    }
 else     if (message.isMimeType("String_Node_Str") || message.isMimeType("String_Node_Str")) {
      s=new SMIMESigned(message);
    }
 else {
      ErrorBundle msg=new ErrorBundle(RESOURCE_NAME,"String_Node_Str");
      throw new SignedMailValidatorException(msg);
    }
    certs=new JcaCertStoreBuilder().addCertificates(s.getCertificates()).addCRLs(s.getCRLs()).setProvider("String_Node_Str").build();
    signers=s.getSignerInfos();
    Address[] froms=message.getFrom();
    InternetAddress sender=null;
    try {
      if (message.getHeader("String_Node_Str") != null) {
        sender=new InternetAddress(message.getHeader("String_Node_Str")[0]);
      }
    }
 catch (    MessagingException ex) {
    }
    int fromsLength=(froms != null) ? froms.length : 0;
    fromAddresses=new String[fromsLength + ((sender != null) ? 1 : 0)];
    for (int i=0; i < fromsLength; i++) {
      InternetAddress inetAddr=(InternetAddress)froms[i];
      fromAddresses[i]=inetAddr.getAddress();
    }
    if (sender != null) {
      fromAddresses[fromsLength]=sender.getAddress();
    }
    results=new HashMap();
  }
 catch (  Exception e) {
    if (e instanceof SignedMailValidatorException) {
      throw (SignedMailValidatorException)e;
    }
    ErrorBundle msg=new ErrorBundle(RESOURCE_NAME,"String_Node_Str",new Object[]{e.getMessage(),e,e.getClass().getName()});
    throw new SignedMailValidatorException(msg,e);
  }
  validateSignatures(param);
}