Program: 89812
Project: 89812
Buggy source:
private List<ServiceOfferingVO> searchServiceOfferingsInternal(Account account,Object name,Object id,Long vmId,Object keyword,Filter searchFilter){
  List<ServiceOfferingVO> sol=new ArrayList<ServiceOfferingVO>();
  DomainVO domainRecord=_domainDao.findById(account.getDomainId());
  boolean includePublicOfferings=true;
  if (domainRecord != null) {
    while (true) {
      SearchCriteria<ServiceOfferingVO> sc=_offeringsDao.createSearchCriteria();
      if (keyword != null) {
        includePublicOfferings=false;
        SearchCriteria<ServiceOfferingVO> ssc=_offeringsDao.createSearchCriteria();
        ssc.addOr("String_Node_Str",SearchCriteria.Op.LIKE,"String_Node_Str" + keyword + "String_Node_Str");
        ssc.addOr("String_Node_Str",SearchCriteria.Op.LIKE,"String_Node_Str" + keyword + "String_Node_Str");
        sc.addAnd("String_Node_Str",SearchCriteria.Op.SC,ssc);
      }
 else       if (vmId != null) {
        includePublicOfferings=false;
        UserVmVO vmInstance=_userVmDao.findById(vmId);
        if ((vmInstance == null) || (vmInstance.getRemoved() != null)) {
          throw new InvalidParameterValueException("String_Node_Str" + vmId);
        }
        if ((account != null) && !isAdmin(account.getType())) {
          if (account.getId() != vmInstance.getAccountId()) {
            throw new PermissionDeniedException("String_Node_Str" + vmId + "String_Node_Str");
          }
        }
        ServiceOfferingVO offering=_offeringsDao.findById(vmInstance.getServiceOfferingId());
        sc.addAnd("String_Node_Str",SearchCriteria.Op.NEQ,offering.getId());
        sc.addAnd("String_Node_Str",SearchCriteria.Op.EQ,offering.getGuestIpType());
        sc.addAnd("String_Node_Str",SearchCriteria.Op.EQ,offering.getUseLocalStorage());
      }
      if (id != null) {
        includePublicOfferings=false;
        sc.addAnd("String_Node_Str",SearchCriteria.Op.EQ,id);
      }
      if (name != null) {
        includePublicOfferings=false;
        sc.addAnd("String_Node_Str",SearchCriteria.Op.LIKE,"String_Node_Str" + name + "String_Node_Str");
      }
      sc.addAnd("String_Node_Str",SearchCriteria.Op.EQ,false);
      sc.addAnd("String_Node_Str",SearchCriteria.Op.EQ,domainRecord.getId());
      sol.addAll(_offeringsDao.search(sc,searchFilter));
      if (domainRecord.getParent() != null) {
        domainRecord=_domainDao.findById(domainRecord.getParent());
      }
 else {
        break;
      }
    }
  }
 else {
    s_logger.error("String_Node_Str" + account.getAccountName());
    throw new CloudAuthenticationException("String_Node_Str" + account.getAccountName());
  }
  if (includePublicOfferings) {
    sol.addAll(_offeringsDao.findPublicServiceOfferings());
  }
  return sol;
}

Fixed version (ground truth):
private List<ServiceOfferingVO> searchServiceOfferingsInternal(Account account,Object name,Object id,Long vmId,Object keyword,Filter searchFilter){
  List<ServiceOfferingVO> sol=new ArrayList<ServiceOfferingVO>();
  DomainVO domainRecord=_domainDao.findById(account.getDomainId());
  boolean includePublicOfferings=true;
  if (domainRecord != null) {
    while (true) {
      SearchCriteria<ServiceOfferingVO> sc=_offeringsDao.createSearchCriteria();
      if (keyword != null) {
        includePublicOfferings=false;
        SearchCriteria<ServiceOfferingVO> ssc=_offeringsDao.createSearchCriteria();
        ssc.addOr("String_Node_Str",SearchCriteria.Op.LIKE,"String_Node_Str" + keyword + "String_Node_Str");
        ssc.addOr("String_Node_Str",SearchCriteria.Op.LIKE,"String_Node_Str" + keyword + "String_Node_Str");
        sc.addAnd("String_Node_Str",SearchCriteria.Op.SC,ssc);
      }
 else       if (vmId != null) {
        UserVmVO vmInstance=_userVmDao.findById(vmId);
        if ((vmInstance == null) || (vmInstance.getRemoved() != null)) {
          throw new InvalidParameterValueException("String_Node_Str" + vmId);
        }
        if ((account != null) && !isAdmin(account.getType())) {
          if (account.getId() != vmInstance.getAccountId()) {
            throw new PermissionDeniedException("String_Node_Str" + vmId + "String_Node_Str");
          }
        }
        ServiceOfferingVO offering=_offeringsDao.findById(vmInstance.getServiceOfferingId());
        sc.addAnd("String_Node_Str",SearchCriteria.Op.NEQ,offering.getId());
        sc.addAnd("String_Node_Str",SearchCriteria.Op.EQ,offering.getGuestIpType());
        sc.addAnd("String_Node_Str",SearchCriteria.Op.EQ,offering.getUseLocalStorage());
      }
      if (id != null) {
        includePublicOfferings=false;
        sc.addAnd("String_Node_Str",SearchCriteria.Op.EQ,id);
      }
      if (name != null) {
        includePublicOfferings=false;
        sc.addAnd("String_Node_Str",SearchCriteria.Op.LIKE,"String_Node_Str" + name + "String_Node_Str");
      }
      sc.addAnd("String_Node_Str",SearchCriteria.Op.EQ,false);
      sc.addAnd("String_Node_Str",SearchCriteria.Op.EQ,domainRecord.getId());
      sol.addAll(_offeringsDao.search(sc,searchFilter));
      if (domainRecord.getParent() != null) {
        domainRecord=_domainDao.findById(domainRecord.getParent());
      }
 else {
        break;
      }
    }
  }
 else {
    s_logger.error("String_Node_Str" + account.getAccountName());
    throw new CloudAuthenticationException("String_Node_Str" + account.getAccountName());
  }
  if (includePublicOfferings) {
    sol.addAll(_offeringsDao.findPublicServiceOfferings());
  }
  return sol;
}