(/home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/csids.c) |
| |
| 61 | | | int csids_open(wtap *wth, int *err, gchar **err_info _U_) |
| 62 | | | { |
| 63 | | | |
| 64 | | | |
| 65 | | | |
| 66 | | | |
| 67 | | | |
| 68 | | | |
| 69 | | | |
| 70 | | | |
| 71 | | | int tmp,iplen,bytesRead; |
| 72 | | | |
| 73 | | | gboolean byteswap = FALSE; |
| 74 | | | struct hdr; |
| 75 | | | bytesRead=0; |
| 76 | | | |
| 77 | | | |
| 78 | | | bytesRead = file_read( &hdr, 1, sizeof( struct ), wth->fh );
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/file_wrappers.h |
| |
36 | #define file_read(buf, bsize, count, file) gzread((file),(buf),(unsigned)((count)*(bsize))) |
| |
|
| 79 | | | if( bytesRead != sizeof( struct ) ) { |
| 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 );
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/wtap-int.h |
| |
354 | #define pntohl(p) ((guint32)*((const guint8 *)(p)+0)<<24| \ |
355 | (guint32)*((const guint8 *)(p)+1)<<16| \ |
356 | (guint32)*((const guint8 *)(p)+2)<<8| \ |
357 | (guint32)*((const guint8 *)(p)+3)<<0) |
| |
|
| 91 | | | hdr.caplen = pntohs( &hdr.caplen );
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/wtap-int.h |
| |
342 | #define pntohs(p) ((guint16) \ |
343 | ((guint16)*((const guint8 *)(p)+0)<<8| \ |
344 | (guint16)*((const guint8 *)(p)+1)<<0)) |
| |
|
| 92 | | | bytesRead = file_read( &tmp, 1, 2, wth->fh );
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/file_wrappers.h |
| |
36 | #define file_read(buf, bsize, count, file) gzread((file),(buf),(unsigned)((count)*(bsize))) |
| |
|
| 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 );
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/file_wrappers.h |
| |
36 | #define file_read(buf, bsize, count, file) gzread((file),(buf),(unsigned)((count)*(bsize))) |
| |
|
| 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);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/wtap-int.h |
| |
342 | #define pntohs(p) ((guint16) \ |
343 | ((guint16)*((const guint8 *)(p)+0)<<8| \ |
344 | (guint16)*((const guint8 *)(p)+1)<<0)) |
| |
|
| 111 | | | |
| 112 | | | if ( iplen == 0 ) |
| 113 | | | return(0); |
| 114 | | | |
| 115 | | | |
| 116 | | | if( iplen > hdr.caplen ) { |
| 117 | | | |
| 118 | | | |
| 119 | | | |
| 120 | | | iplen = BSWAP16(iplen); |
| 121 | | | if( iplen <= hdr.caplen ) { |
| 122 | | | |
| 123 | | | byteswap = TRUE; |
| 124 | | | } else { |
| 125 | | | |
| 126 | | | return 0; |
| 127 | | | } |
| 128 | | | } else { |
| 129 | | | byteswap = FALSE; |
Useless Assignment
This code assigns the variable the same value it already had. |
|
| 130 | | | } |
| 131 | | | |
| 132 | | | |
| 133 | | | if (file_seek(wth->fh, 0, SEEK_SET, err) == -1)
x /usr/include/stdio.h |
| |
141 | #define SEEK_SET 0 /* Seek from beginning of file. */ |
| |
|
| 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; |
| 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 | | | } |
| |