Text   |  XML   |  ReML   |   Visible Warnings:

Useless Assignment  at csids.c:129

No properties have been set. | edit properties
Jump to warning location ↓ warning details...
Show Events | Options

csids_open

(/home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/csids.c)expand/collapse
Show more  
 61  int csids_open(wtap *wth, int *err, gchar **err_info _U_)
 62  {
 63    /* There is no file header. There is only a header for each packet
 64     * so we read a packet header and compare the caplen with iplen. They 
 65     * should always be equal except with the wierd byteswap version.
 66     *
 67     * THIS IS BROKEN-- anytime the caplen is 0x0101 or 0x0202 up to 0x0505
 68     * this will byteswap it. I need to fix this. XXX --mlh
 69     */
 70   
 71    int tmp,iplen,bytesRead;
 72   
 73    gboolean byteswap = FALSE;
 74    struct csids_header hdr;
 75    bytesRead=0;
 76   
 77    /* check the file to make sure it is a csids file. */
 78    bytesRead = file_read( &hdr, 1, sizeof( struct csids_header), wth->fh );
 79    if( bytesRead != sizeof( struct csids_header) ) {
 80      *err = file_error( wth->fh );
 81      if( *err != 0 ) {
 82        return -1;
 83      } else {
 84        return 0;
 85      }
 86    }
 87    if( hdr.zeropad != 0 || hdr.caplen == 0 ) {
 88          return 0;
 89    }
 90    hdr.seconds = pntohl( &hdr.seconds );
 91    hdr.caplen = pntohs( &hdr.caplen );
 92    bytesRead = file_read( &tmp, 1, 2, wth->fh );
 93    if( bytesRead != 2 ) {
 94      *err = file_error( wth->fh );
 95      if( *err != 0 ) {
 96        return -1;
 97      } else {
 98        return 0;
 99      }
 100    }
 101    bytesRead = file_read( &iplen, 1, 2, wth->fh );
 102    if( bytesRead != 2 ) {
 103      *err = file_error( wth->fh );
 104      if( *err != 0 ) {
 105        return -1;
 106      } else {
 107        return 0;
 108      }
 109    }
 110    iplen = pntohs(&iplen);
 111   
 112    if ( iplen == 0 )
 113      return(0);
 114   
 115    /* if iplen and hdr.caplen are equal, default to no byteswap. */
 116    if( iplen > hdr.caplen ) {
 117      /* maybe this is just a byteswapped version. the iplen ipflags */
 118      /* and ipid are swapped. We cannot use the normal swaps because */
 119      /* we don't know the host */
 120      iplen = BSWAP16(iplen);
 121      if( iplen <= hdr.caplen ) {
 122        /* we know this format */
 123        byteswap = TRUE;
 124      } else {
 125        /* don't know this one */
 126        return 0;
 127      }
 128    } else {
 129      byteswap = FALSE;
 130    }
 131   
 132    /* no file header. So reset the fh to 0 so we can read the first packet */
 133    if (file_seek(wth->fh, 0, SEEK_SET, err) == -1)
 134      return -1;
 135   
 136    wth->data_offset = 0;
 137    wth->capture.csids = g_malloc(sizeof(csids_t));
 138    wth->capture.csids->byteswapped = byteswap;
 139    wth->file_encap = WTAP_ENCAP_RAW_IP;
 140    wth->file_type = WTAP_FILE_CSIDS;
 141    wth->snapshot_length = 0; /* not known */
 142    wth->subtype_read = csids_read;
 143    wth->subtype_seek_read = csids_seek_read;
 144    wth->subtype_close = csids_close;
 145    wth->tsprecision = WTAP_FILE_TSPREC_SEC;
 146   
 147    return 1;
 148  }
Show more  




Change Warning 989.29830 : Useless Assignment

Priority:
State:
Finding:
Owner:
Note: