(/home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/lanalyzer.c) |
| |
| 276 | | | static gboolean lanalyzer_read(wtap *wth, int *err, gchar **err_info, |
| 277 | | | gint64 *data_offset) |
| 278 | | | { |
| 279 | | | int packet_size = 0; |
| 280 | | | int bytes_read; |
| 281 | | | char LE_record_type[2]; |
| 282 | | | char LE_record_length[2]; |
| 283 | | | guint16 record_type, record_length; |
| 284 | | | gchar descriptor[DESCRIPTOR_LEN]; |
| 285 | | | guint16 time_low, time_med, time_high, true_size; |
| 286 | | | guint64 t; |
| 287 | | | time_t tsecs; |
| 288 | | | |
| 289 | | | |
| 290 | | | errno = WTAP_ERR_CANT_READ; |
| 291 | | | 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))) |
| |
|
| 292 | | | if (bytes_read != 2) { |
| 293 | | | *err = file_error(wth->fh); |
| 294 | | | if (*err == 0 && bytes_read != 0) { |
| 295 | | | *err = WTAP_ERR_SHORT_READ; |
| 296 | | | } |
| 297 | | | return FALSE; |
| 298 | | | } |
| 299 | | | wth->data_offset += 2; |
| 300 | | | 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))) |
| |
|
| 301 | | | if (bytes_read != 2) { |
| 302 | | | *err = file_error(wth->fh); |
| 303 | | | if (*err == 0) |
| 304 | | | *err = WTAP_ERR_SHORT_READ; |
| 305 | | | return FALSE; |
| 306 | | | } |
| 307 | | | wth->data_offset += 2; |
| 308 | | | |
| 309 | | | 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)) |
| |
|
| 310 | | | 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)) |
| |
|
| 311 | | | |
| 312 | | | |
| 313 | | | |
| 314 | | | |
| 315 | | | if (record_type != RT_PacketData) { |
| 316 | | | *err = WTAP_ERR_BAD_RECORD; |
| 317 | | | *err_info = g_strdup_printf("lanalyzer: record type %u seen after trace summary record", |
| 318 | | | record_type); |
| 319 | | | return FALSE; |
| 320 | | | } |
| 321 | | | else { |
| 322 | | | packet_size = record_length - DESCRIPTOR_LEN; |
| 323 | | | } |
| 324 | | | |
| 325 | | | |
| 326 | | | errno = WTAP_ERR_CANT_READ; |
Useless Assignment
This code assigns the variable the same value it already had. |
|
| 327 | | | bytes_read = file_read(descriptor, 1, DESCRIPTOR_LEN, 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))) |
| |
|
| 328 | | | if (bytes_read != DESCRIPTOR_LEN) { |
| 329 | | | *err = file_error(wth->fh); |
| 330 | | | if (*err == 0) |
| 331 | | | *err = WTAP_ERR_SHORT_READ; |
| 332 | | | return FALSE; |
| 333 | | | } |
| 334 | | | wth->data_offset += DESCRIPTOR_LEN; |
| 335 | | | |
| 336 | | | |
| 337 | | | buffer_assure_space(wth->frame_buffer, packet_size); |
| 338 | | | *data_offset = wth->data_offset; |
| 339 | | | errno = WTAP_ERR_CANT_READ; |
| 340 | | | bytes_read = file_read(buffer_start_ptr(wth->frame_buffer), 1,
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))) |
| |
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/buffer.h |
| |
46 | # define buffer_start_ptr(buffer) ((buffer)->data + (buffer)->start) |
| |
|
| 341 | | | packet_size, wth->fh); |
| 342 | | | |
| 343 | | | if (bytes_read != packet_size) { |
| 344 | | | *err = file_error(wth->fh); |
| 345 | | | if (*err == 0) |
| 346 | | | *err = WTAP_ERR_SHORT_READ; |
| 347 | | | return FALSE; |
| 348 | | | } |
| 349 | | | wth->data_offset += packet_size; |
| 350 | | | |
| 351 | | | true_size = pletohs(&descriptor[4]);
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)) |
| |
|
| 352 | | | packet_size = pletohs(&descriptor[6]);
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)) |
| |
|
| 353 | | | |
| 354 | | | |
| 355 | | | |
| 356 | | | |
| 357 | | | |
| 358 | | | if (packet_size > record_length - DESCRIPTOR_LEN) { |
| 359 | | | |
| 360 | | | |
| 361 | | | |
| 362 | | | *err = WTAP_ERR_BAD_RECORD; |
| 363 | | | *err_info = g_strdup("lanalyzer: Record length is less than packet size"); |
| 364 | | | return FALSE; |
| 365 | | | } |
| 366 | | | |
| 367 | | | time_low = pletohs(&descriptor[8]);
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)) |
| |
|
| 368 | | | time_med = pletohs(&descriptor[10]);
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)) |
| |
|
| 369 | | | time_high = pletohs(&descriptor[12]);
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)) |
| |
|
| 370 | | | t = (((guint64)time_low) << 0) + (((guint64)time_med) << 16) + |
| 371 | | | (((guint64)time_high) << 32); |
| 372 | | | tsecs = (time_t) (t/2000000); |
| 373 | | | wth->phdr.ts.secs = tsecs + wth->capture.lanalyzer->start; |
| 374 | | | wth->phdr.ts.nsecs = ((guint32) (t - tsecs*2000000)) * 500; |
| 375 | | | |
| 376 | | | if (true_size - 4 >= packet_size) { |
| 377 | | | |
| 378 | | | |
| 379 | | | |
| 380 | | | |
| 381 | | | |
| 382 | | | |
| 383 | | | true_size -= 4; |
| 384 | | | } |
| 385 | | | wth->phdr.len = true_size; |
| 386 | | | wth->phdr.caplen = packet_size; |
| 387 | | | |
| 388 | | | switch (wth->file_encap) { |
| 389 | | | |
| 390 | | | case WTAP_ENCAP_ETHERNET: |
| 391 | | | |
| 392 | | | wth->.eth.fcs_len = 0; |
| 393 | | | break; |
| 394 | | | } |
| 395 | | | |
| 396 | | | return TRUE; |
| 397 | | | } |
| |