(/home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/etherpeek.c) |
| |
| 535 | | | static gboolean etherpeek_read_v56(wtap *wth, int *err, gchar **err_info _U_, |
| 536 | | | gint64 *data_offset) |
| 537 | | | { |
| 538 | | | guchar ep_pkt[ETHERPEEK_V56_PKT_SIZE]; |
| 539 | | | guint16 length; |
| 540 | | | guint16 sliceLength; |
| 541 | | | guint8 flags; |
| 542 | | | guint8 status; |
| 543 | | | guint32 timestamp; |
| 544 | | | guint16 destNum; |
| 545 | | | guint16 srcNum; |
| 546 | | | guint16 protoNum; |
| 547 | | | char protoStr[8]; |
| 548 | | | unsigned int i; |
| 549 | | | |
| 550 | | | |
| 551 | | | |
| 552 | | | |
| 553 | | | |
| 554 | | | |
| 555 | | | |
| 556 | | | |
| 557 | | | |
| 558 | | | |
| 559 | | | |
| 560 | | | *data_offset = wth->data_offset; |
| 561 | | | |
| 562 | | | wtap_file_read_expected_bytes(ep_pkt, sizeof(ep_pkt), wth->fh, err);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/wtap-int.h |
| |
466 | #define wtap_file_read_expected_bytes(target, num_bytes, fh, err) \ |
467 | G_STMT_START \ |
468 | { \ |
469 | int _bytes_read; \ |
470 | _bytes_read = file_read((target), 1, (num_bytes), (fh)); \ |
471 | if (_bytes_read != (int) (num_bytes)) { \ |
472 | *(err) = file_error((fh)); \ |
473 | if (*(err) == 0 && _bytes_read > 0) { \ |
474 | *(err) = WTAP_ERR_SHORT_READ; \ |
475 | } \ |
476 | return FALSE; \ |
477 | } \ |
478 | } \ |
479 | G_STMT_END |
| |
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))) |
| |
|
| 563 | | | wth->data_offset += sizeof(ep_pkt); |
| 564 | | | |
| 565 | | | |
| 566 | | | length = pntohs(&ep_pkt[ETHERPEEK_V56_LENGTH_OFFSET]);
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)) |
| |
|
| 567 | | | sliceLength = pntohs(&ep_pkt[ETHERPEEK_V56_SLICE_LENGTH_OFFSET]);
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)) |
| |
|
| 568 | | | flags = ep_pkt[ETHERPEEK_V56_FLAGS_OFFSET]; |
| 569 | | | status = ep_pkt[ETHERPEEK_V56_STATUS_OFFSET]; |
| 570 | | | timestamp = pntohl(&ep_pkt[ETHERPEEK_V56_TIMESTAMP_OFFSET]);
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) |
| |
|
| 571 | | | destNum = pntohs(&ep_pkt[ETHERPEEK_V56_DESTNUM_OFFSET]);
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)) |
| |
|
Unused Value
The value assigned to destNum is never subsequently used on any execution path. |
|
| 572 | | | srcNum = pntohs(&ep_pkt[ETHERPEEK_V56_SRCNUM_OFFSET]);
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)) |
| |
|
| 573 | | | protoNum = pntohs(&ep_pkt[ETHERPEEK_V56_PROTONUM_OFFSET]);
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)) |
| |
|
| 574 | | | memcpy(protoStr, &ep_pkt[ETHERPEEK_V56_PROTOSTR_OFFSET], |
| 575 | | | sizeof protoStr); |
| 576 | | | |
| 577 | | | |
| 578 | | | |
| 579 | | | |
| 580 | | | |
| 581 | | | |
| 582 | | | |
| 583 | | | if (0 == sliceLength) { |
| 584 | | | sliceLength = length; |
| 585 | | | } |
| 586 | | | |
| 587 | | | |
| 588 | | | buffer_assure_space(wth->frame_buffer, sliceLength); |
| 589 | | | wtap_file_read_expected_bytes(buffer_start_ptr(wth->frame_buffer),
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/wtap-int.h |
| |
466 | #define wtap_file_read_expected_bytes(target, num_bytes, fh, err) \ |
467 | G_STMT_START \ |
468 | { \ |
469 | int _bytes_read; \ |
470 | _bytes_read = file_read((target), 1, (num_bytes), (fh)); \ |
471 | if (_bytes_read != (int) (num_bytes)) { \ |
472 | *(err) = file_error((fh)); \ |
473 | if (*(err) == 0 && _bytes_read > 0) { \ |
474 | *(err) = WTAP_ERR_SHORT_READ; \ |
475 | } \ |
476 | return FALSE; \ |
477 | } \ |
478 | } \ |
479 | G_STMT_END |
| |
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) |
| |
|
| 590 | | | sliceLength, wth->fh, err); |
| 591 | | | wth->data_offset += sliceLength; |
| 592 | | | |
| 593 | | | |
| 594 | | | wth->phdr.len = length; |
| 595 | | | wth->phdr.caplen = sliceLength; |
| 596 | | | |
| 597 | | | wth->phdr.ts.secs = wth->capture.etherpeek->reference_time.tv_sec |
| 598 | | | + (timestamp / 1000); |
| 599 | | | wth->phdr.ts.nsecs = 1000 * (timestamp % 1000) * 1000; |
| 600 | | | |
| 601 | | | wth->phdr.pkt_encap = WTAP_ENCAP_UNKNOWN; |
| 602 | | | for (i=0; i<NUM_ETHERPEEK_ENCAPS; i++) {
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/etherpeek.c |
| |
142 | #define NUM_ETHERPEEK_ENCAPS \ |
143 | (sizeof (etherpeek_encap) / sizeof (etherpeek_encap[0])) |
| |
|
| 603 | | | if (etherpeek_encap[i].protoNum == protoNum) { |
| 604 | | | wth->phdr.pkt_encap = etherpeek_encap[i].encap; |
| 605 | | | } |
| 606 | | | } |
| 607 | | | |
| 608 | | | switch (wth->phdr.pkt_encap) { |
| 609 | | | |
| 610 | | | case WTAP_ENCAP_ETHERNET: |
| 611 | | | |
| 612 | | | wth->.eth.fcs_len = 0; |
| 613 | | | break; |
| 614 | | | } |
| 615 | | | return TRUE; |
| 616 | | | } |
| |