Program: 172286
Project: 172286
Buggy source:
/** 
 * Authenticate a session setup by a user
 * @param client ClientInfo
 * @param sess SrvSession
 * @param alg int
 * @return int
 */
public int authenticateUser(ClientInfo client,SrvSession sess,int alg){
  if (client.isNullSession()) {
    if (logger.isDebugEnabled())     logger.debug("String_Node_Str");
    return CifsAuthenticator.AUTH_ALLOW;
  }
  sess.beginReadTransaction(m_transactionService);
  if (client.getAuthenticationToken() != null && client.getLogonType() != ClientInfo.LogonNull) {
    m_authComponent.setCurrentUser(mapUserNameToPerson(client.getUserName()));
    if (logger.isDebugEnabled())     logger.debug("String_Node_Str");
    return client.getLogonType() != ClientInfo.LogonGuest ? AUTH_ALLOW : AUTH_GUEST;
  }
  int authSts=AUTH_DISALLOW;
  if (client.isGuest() || client.getUserName().equalsIgnoreCase(getGuestUserName())) {
    if (allowGuest() == false)     return AUTH_DISALLOW;
    doGuestLogon(client,sess);
    authSts=AUTH_GUEST;
    if (logger.isDebugEnabled())     logger.debug("String_Node_Str" + client.getUserName() + "String_Node_Str"+ getStatusAsString(authSts));
    return authSts;
  }
  PassthruDetails passDetails=m_sessions.get(sess.getUniqueId());
  if (passDetails != null) {
    try {
      AuthenticateSession authSess=passDetails.getAuthenticateSession();
      authSess.doSessionSetup(client.getDomain(),client.getUserName(),null,client.getANSIPassword(),client.getPassword());
      if (authSess.isGuest()) {
        if (allowGuest() == true) {
          doGuestLogon(client,sess);
          authSts=CifsAuthenticator.AUTH_GUEST;
          if (logger.isDebugEnabled())           logger.debug("String_Node_Str" + client.getUserName() + "String_Node_Str");
        }
      }
 else {
        String username=client.getUserName();
        String personName=m_personService.getUserIdentifier(username);
        if (personName != null) {
          m_authComponent.setCurrentUser(personName);
          if (logger.isDebugEnabled())           logger.debug("String_Node_Str" + personName + "String_Node_Str"+ username+ "String_Node_Str");
          authSts=CifsAuthenticator.AUTH_ALLOW;
          if (logger.isDebugEnabled())           logger.debug("String_Node_Str" + client.getUserName() + "String_Node_Str");
        }
 else         if (logger.isDebugEnabled())         logger.debug("String_Node_Str" + username);
      }
    }
 catch (    Exception ex) {
      logger.error(ex.getMessage());
    }
    if ((sess instanceof SMBSrvSession) == false) {
      m_sessions.remove(sess.getUniqueId());
      try {
        AuthenticateSession authSess=passDetails.getAuthenticateSession();
        authSess.CloseSession();
        if (logger.isDebugEnabled())         logger.debug("String_Node_Str" + authSess.getSessionId());
      }
 catch (      Exception ex) {
        logger.error("String_Node_Str",ex);
      }
    }
  }
 else {
    if (logger.isDebugEnabled())     logger.debug("String_Node_Str" + sess.getUniqueId());
  }
  return authSts;
}

Fixed version (ground truth):
/** 
 * Authenticate a session setup by a user
 * @param client ClientInfo
 * @param sess SrvSession
 * @param alg int
 * @return int
 */
public int authenticateUser(ClientInfo client,SrvSession sess,int alg){
  if (client.isNullSession()) {
    if (logger.isDebugEnabled())     logger.debug("String_Node_Str");
    return CifsAuthenticator.AUTH_ALLOW;
  }
  sess.beginReadTransaction(m_transactionService);
  if (client.getAuthenticationToken() != null && client.getLogonType() != ClientInfo.LogonNull) {
    m_authComponent.setCurrentUser(mapUserNameToPerson(client.getUserName()));
    if (logger.isDebugEnabled())     logger.debug("String_Node_Str");
    return client.getLogonType() != ClientInfo.LogonGuest ? AUTH_ALLOW : AUTH_GUEST;
  }
  int authSts=AUTH_DISALLOW;
  if (client.isGuest() || client.getUserName().equalsIgnoreCase(getGuestUserName())) {
    if (allowGuest() == false)     return AUTH_DISALLOW;
    doGuestLogon(client,sess);
    authSts=AUTH_GUEST;
    if (logger.isDebugEnabled())     logger.debug("String_Node_Str" + client.getUserName() + "String_Node_Str"+ getStatusAsString(authSts));
    return authSts;
  }
  PassthruDetails passDetails=m_sessions.get(sess.getUniqueId());
  if (passDetails != null) {
    try {
      AuthenticateSession authSess=passDetails.getAuthenticateSession();
      authSess.doSessionSetup(client.getDomain(),client.getUserName(),null,client.getANSIPassword(),client.getPassword());
      if (authSess.isGuest()) {
        if (allowGuest() == true) {
          doGuestLogon(client,sess);
          authSts=CifsAuthenticator.AUTH_GUEST;
          if (logger.isDebugEnabled())           logger.debug("String_Node_Str" + client.getUserName() + "String_Node_Str");
        }
      }
 else {
        String username=client.getUserName();
        String personName=m_personService.getUserIdentifier(username);
        if (personName != null) {
          client.setAuthenticationToken(m_authComponent.setCurrentUser(personName));
          if (logger.isDebugEnabled())           logger.debug("String_Node_Str" + personName + "String_Node_Str"+ username+ "String_Node_Str");
          authSts=CifsAuthenticator.AUTH_ALLOW;
          if (logger.isDebugEnabled())           logger.debug("String_Node_Str" + client.getUserName() + "String_Node_Str");
        }
 else         if (logger.isDebugEnabled())         logger.debug("String_Node_Str" + username);
      }
    }
 catch (    Exception ex) {
      logger.error(ex.getMessage());
    }
    if ((sess instanceof SMBSrvSession) == false) {
      m_sessions.remove(sess.getUniqueId());
      try {
        AuthenticateSession authSess=passDetails.getAuthenticateSession();
        authSess.CloseSession();
        if (logger.isDebugEnabled())         logger.debug("String_Node_Str" + authSess.getSessionId());
      }
 catch (      Exception ex) {
        logger.error("String_Node_Str",ex);
      }
    }
  }
 else {
    if (logger.isDebugEnabled())     logger.debug("String_Node_Str" + sess.getUniqueId());
  }
  return authSts;
}