(/home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/lanalyzer.c) |
| |
| 128 | | | int lanalyzer_open(wtap *wth, int *err, gchar **err_info) |
| 129 | | | { |
| 130 | | | int bytes_read; |
| 131 | | | char LE_record_type[2]; |
| 132 | | | char LE_record_length[2]; |
| 133 | | | char summary[210]; |
| 134 | | | guint16 board_type, mxslc; |
| 135 | | | guint16 record_type, record_length; |
| 136 | | | guint8 cr_day, cr_month; |
| 137 | | | guint16 cr_year; |
| 138 | | | struct tm tm; |
| 139 | | | |
| 140 | | | errno = WTAP_ERR_CANT_READ; |
| 141 | | | bytes_read = file_read(LE_record_type, 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))) |
| |
|
| 142 | | | bytes_read += file_read(LE_record_length, 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))) |
| |
|
| 143 | | | if (bytes_read != 4) { |
| 144 | | | *err = file_error(wth->fh); |
| 145 | | | if (*err != 0) |
| 146 | | | return -1; |
| 147 | | | return 0; |
| 148 | | | } |
| 149 | | | wth->data_offset += 4; |
| 150 | | | record_type = pletohs(LE_record_type);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/wtap-int.h |
| |
373 | #define pletohs(p) ((guint16) \ |
374 | ((guint16)*((const guint8 *)(p)+1)<<8| \ |
375 | (guint16)*((const guint8 *)(p)+0)<<0)) |
| |
|
| 151 | | | record_length = pletohs(LE_record_length);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/wtap-int.h |
| |
373 | #define pletohs(p) ((guint16) \ |
374 | ((guint16)*((const guint8 *)(p)+1)<<8| \ |
375 | (guint16)*((const guint8 *)(p)+0)<<0)) |
| |
|
| 152 | | | |
| 153 | | | if (record_type != && record_type != ) { |
| 154 | | | return 0; |
| 155 | | | } |
| 156 | | | |
| 157 | | | |
| 158 | | | |
| 159 | | | |
| 160 | | | wth->file_type = WTAP_FILE_LANALYZER; |
| 161 | | | wth->capture.lanalyzer = g_malloc(sizeof(lanalyzer_t)); |
| 162 | | | wth->subtype_read = lanalyzer_read; |
| 163 | | | wth->subtype_seek_read = lanalyzer_seek_read; |
| 164 | | | wth->subtype_close = lanalyzer_close; |
| 165 | | | wth->snapshot_length = 0; |
| 166 | | | wth->tsprecision = WTAP_FILE_TSPREC_NSEC; |
| 167 | | | |
| 168 | | | |
| 169 | | | while (1) { |
| 170 | | | if (file_seek(wth->fh, record_length, SEEK_CUR, err) == -1) {
x /usr/include/stdio.h |
| |
142 | #define SEEK_CUR 1 /* Seek from current position. */ |
| |
|
| 171 | | | g_free(wth->capture.lanalyzer); |
| 172 | | | return -1; |
| 173 | | | } |
| 174 | | | wth->data_offset += record_length; |
| 175 | | | errno = WTAP_ERR_CANT_READ; |
| 176 | | | bytes_read = file_read(LE_record_type, 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))) |
| |
|
| 177 | | | bytes_read += file_read(LE_record_length, 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))) |
| |
|
| 178 | | | if (bytes_read != 4) { |
| 179 | | | *err = file_error(wth->fh); |
| 180 | | | if (*err != 0) { |
| 181 | | | g_free(wth->capture.lanalyzer); |
| 182 | | | return -1; |
| 183 | | | } |
| 184 | | | g_free(wth->capture.lanalyzer); |
| 185 | | | return 0; |
| 186 | | | } |
| 187 | | | wth->data_offset += 4; |
| 188 | | | |
| 189 | | | record_type = pletohs(LE_record_type);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/wtap-int.h |
| |
373 | #define pletohs(p) ((guint16) \ |
374 | ((guint16)*((const guint8 *)(p)+1)<<8| \ |
375 | (guint16)*((const guint8 *)(p)+0)<<0)) |
| |
|
| 190 | | | record_length = pletohs(LE_record_length);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/wtap-int.h |
| |
373 | #define pletohs(p) ((guint16) \ |
374 | ((guint16)*((const guint8 *)(p)+1)<<8| \ |
375 | (guint16)*((const guint8 *)(p)+0)<<0)) |
| |
|
| 191 | | | |
| 192 | | | |
| 193 | | | switch (record_type) { |
| 194 | | | |
| 195 | | | case RT_Summary: |
| 196 | | | errno = WTAP_ERR_CANT_READ; |
Useless Assignment
This code assigns the variable the same value it already had. |
|
| 197 | | | bytes_read = file_read(summary, 1, sizeof summary,
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))) |
| |
|
| 198 | | | wth->fh); |
| 199 | | | if (bytes_read != sizeof summary) { |
| 200 | | | *err = file_error(wth->fh); |
| 201 | | | if (*err != 0) { |
| 202 | | | g_free(wth->capture.lanalyzer); |
| 203 | | | return -1; |
| 204 | | | } |
| 205 | | | g_free(wth->capture.lanalyzer); |
| 206 | | | return 0; |
| 207 | | | } |
| 208 | | | wth->data_offset += sizeof summary; |
| 209 | | | |
| 210 | | | |
| 211 | | | |
| 212 | | | |
| 213 | | | |
| 214 | | | |
| 215 | | | |
| 216 | | | cr_day = summary[0]; |
| 217 | | | cr_month = summary[1]; |
| 218 | | | cr_year = pletohs(&summary[2]);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/wtap-int.h |
| |
373 | #define pletohs(p) ((guint16) \ |
374 | ((guint16)*((const guint8 *)(p)+1)<<8| \ |
375 | (guint16)*((const guint8 *)(p)+0)<<0)) |
| |
|
| 219 | | | |
| 220 | | | |
| 221 | | | |
| 222 | | | |
| 223 | | | |
| 224 | | | |
| 225 | | | tm.tm_year = cr_year - 1900; |
| 226 | | | tm.tm_mon = cr_month - 1; |
| 227 | | | tm.tm_mday = cr_day; |
| 228 | | | tm.tm_hour = 0; |
| 229 | | | tm.tm_min = 0; |
| 230 | | | tm.tm_sec = 0; |
| 231 | | | tm.tm_isdst = -1; |
| 232 | | | wth->capture.lanalyzer->start = mktime(&tm); |
| 233 | | | |
| 234 | | | |
| 235 | | | mxslc = pletohs(&summary[30]);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/wtap-int.h |
| |
373 | #define pletohs(p) ((guint16) \ |
374 | ((guint16)*((const guint8 *)(p)+1)<<8| \ |
375 | (guint16)*((const guint8 *)(p)+0)<<0)) |
| |
|
| 236 | | | wth->snapshot_length = mxslc; |
| 237 | | | |
| 238 | | | record_length = 0; |
| 239 | | | board_type = pletohs(&summary[188]);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/wtap-int.h |
| |
373 | #define pletohs(p) ((guint16) \ |
374 | ((guint16)*((const guint8 *)(p)+1)<<8| \ |
375 | (guint16)*((const guint8 *)(p)+0)<<0)) |
| |
|
| 240 | | | switch (board_type) { |
| 241 | | | case BOARD_325: |
| 242 | | | wth->file_encap = WTAP_ENCAP_ETHERNET; |
| 243 | | | break; |
| 244 | | | case BOARD_325TR: |
| 245 | | | wth->file_encap = WTAP_ENCAP_TOKEN_RING; |
| 246 | | | break; |
| 247 | | | default: |
| 248 | | | g_free(wth->capture.lanalyzer); |
| 249 | | | *err = WTAP_ERR_UNSUPPORTED_ENCAP; |
| 250 | | | *err_info = g_strdup_printf("lanalyzer: board type %u unknown", |
| 251 | | | board_type); |
| 252 | | | return -1; |
| 253 | | | } |
| 254 | | | break; |
| 255 | | | |
| 256 | | | |
| 257 | | | case RT_PacketData: |
| 258 | | | |
| 259 | | | |
| 260 | | | if (file_seek(wth->fh, -bytes_read, SEEK_CUR, err) == -1) {
x /usr/include/stdio.h |
| |
142 | #define SEEK_CUR 1 /* Seek from current position. */ |
| |
|
| 261 | | | g_free(wth->capture.lanalyzer); |
| 262 | | | return -1; |
| 263 | | | } |
| 264 | | | wth->data_offset -= bytes_read; |
| 265 | | | return 1; |
| 266 | | | |
| 267 | | | default: |
| 268 | | | ; |
| 269 | | | } |
| 270 | | | } |
| 271 | | | } |
| |