Changeset 30 for trunk/src/template.c

Show
Ignore:
Timestamp:
04/20/07 16:31:36 (15 years ago)
Author:
andreu
Message:

bug of "template fantom" correction

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/template.c

    r29 r30  
    6767  unsigned char buffer2[2]; 
    6868  unsigned short tmp = 0; 
    69   unsigned short getFlowsetId = 0; 
     69  unsigned short flowsetId = 0; 
    7070  unsigned short length = 0; 
    7171  TplFlowSetPtr ptpltmp = NULL; 
     
    7777  unsigned short badFieldNumber = 0; 
    7878  unsigned short badFieldLength = 0; 
     79  unsigned short badFieldCount = 0; 
    7980 
    8081  buffer2[1]= *(buf+(*offV9)); (*offV9)++; cpt++; 
    8182  buffer2[0]= *(buf+(*offV9)); (*offV9)++; cpt++; 
    82   getFlowsetId = *((unsigned short*)&buffer2); 
     83  flowsetId = *((unsigned short*)&buffer2); 
    8384  buffer2[1]= *(buf+(*offV9)); (*offV9)++; cpt++; 
    8485  buffer2[0]= *(buf+(*offV9)); (*offV9)++; cpt++; 
     
    9091    badFieldNumber = 0; 
    9192    badFieldLength = 0; 
     93    badFieldCount = 0; 
    9294    buffer2[1]= *(buf+(*offV9)); (*offV9)++; cpt++; 
    9395    buffer2[0]= *(buf+(*offV9)); (*offV9)++; cpt++; 
     
    103105      buffer2[1]= *(buf+(*offV9)); (*offV9)++; cpt++; 
    104106      buffer2[0]= *(buf+(*offV9)); (*offV9)++; cpt++; 
    105       cTFSPtr->fieldCount = *((unsigned short*)&buffer2); 
     107      if ( (cTFSPtr->fieldCount = *((unsigned short*)&buffer2) ) == 0 ) { 
     108        badFieldCount = 1; 
     109        ptpltmp = cTFSPtr; 
     110        if (ptpltmp->prev == NULL) { 
     111          cr->tplList = ptpltmp->next; 
     112          if (cr->tplList) { 
     113            cr->tplList->prev = NULL; 
     114          } 
     115        } else { 
     116          ptpltmp->prev->next = ptpltmp->next; 
     117          if (ptpltmp->next) { 
     118            ptpltmp->next->prev = ptpltmp->prev; 
     119          } 
     120        } 
     121        deleteTplFlSet(ptpltmp); 
     122        cTFSPtr = NULL; 
     123        return (-1); 
     124      } 
    106125      cpt_fields = 0; 
    107126      for ( i=0; i<cTFSPtr->fieldCount; i++) { 
     
    125144        } 
    126145        cpt_fields++; 
    127         if ( (cpt_fields > 40) || (badFieldNumber == 1) || badFieldLength == 1) { /* FIXME : constante pour cela */ 
     146        if ( (cTFSPtr->templateFlowSetId < 256 )  
     147             || (cpt_fields > 40)  
     148             || (badFieldNumber == 1)  
     149             || badFieldLength == 1  
     150             || (badFieldCount == 1)) { 
    128151          fprintf(stderr,"\n IP: %lu.%lu.%lu.%lu, %d,%d\n", 
    129152                  cr->IpAddress>>24, 
     
    177200      } 
    178201      deleteTplFlSet(ptpltmp); 
     202      ptpltmp = NULL; 
    179203      cTFSPtr = NULL; 
    180204      cTFSPtr = newRouterTplList(); 
     
    186210      buffer2[1]= *(buf+(*offV9)); (*offV9)++; cpt++; 
    187211      buffer2[0]= *(buf+(*offV9)); (*offV9)++; cpt++; 
    188       cTFSPtr->fieldCount = *((unsigned short*)&buffer2); 
     212      if ( (cTFSPtr->fieldCount = *((unsigned short*)&buffer2) ) == 0 ) { 
     213        badFieldCount = 1; 
     214        ptpltmp = cTFSPtr; 
     215        if (ptpltmp->prev == NULL) { 
     216          cr->tplList = ptpltmp->next; 
     217          if (cr->tplList) { 
     218            cr->tplList->prev = NULL; 
     219          } 
     220        } else { 
     221          ptpltmp->prev->next = ptpltmp->next; 
     222          if (ptpltmp->next) { 
     223            ptpltmp->next->prev = ptpltmp->prev; 
     224          } 
     225        } 
     226        deleteTplFlSet(ptpltmp); 
     227        cTFSPtr = NULL; 
     228        return (-1); 
     229      } 
    189230      cpt_fields = 0; 
    190231      for ( i=0; i<cTFSPtr->fieldCount; i++) { 
     
    210251        } 
    211252        cpt_fields++; 
    212         if ( (cpt_fields > 40) || (badFieldNumber == 1) || badFieldLength == 1) { /* FIXME : declarer une constante pour cela */ 
     253        if ( (cTFSPtr->templateFlowSetId < 256 )  
     254             || (cpt_fields > 40)  
     255             || (badFieldNumber == 1)  
     256             || badFieldLength == 1  
     257             || (badFieldCount == 1)) { 
    213258          while ( ((*offV9))> (index)){ 
    214259            buffer2[1]= *(buf+index); index++; 
     
    355400        } 
    356401        cpt_fields++; 
    357         if ( (cpt_fields > 40) || (badFieldNumber == 1) || badFieldLength == 1) { 
     402        if ( (cTOPtr->templateOptionId < 256) || (cpt_fields > 40) || (badFieldNumber == 1) || badFieldLength == 1) { 
    358403          syslog (LOG_INFO,  
    359404                  "in option template function: too many fields, bug collector or wrong template def in template update"); 
     
    430475        } 
    431476        cpt_fields++; 
    432         if ( (cpt_fields > 40) || (badFieldNumber == 1) || badFieldLength == 1) { 
     477        if ( (cTOPtr->templateOptionId < 256) || (cpt_fields > 40) || (badFieldNumber == 1) || badFieldLength == 1) { 
    433478          syslog (LOG_INFO,  
    434479                  "in update option tpl function: too many fields, bug collector or wrong template def in template update");