(/home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/catapult_dct2000.c) |
| |
| 604 | | | gboolean catapult_dct2000_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, |
| 605 | | | const union *, |
| 606 | | | const guchar *pd, int *err) |
| 607 | | | { |
| 608 | | | guint32 n; |
| 609 | | | line_prefix_info_t *prefix = NULL; |
| 610 | | | gchar time_string[16]; |
| 611 | | | |
| 612 | | | |
| 613 | | | |
| 614 | | | |
| 615 | | | dct2000_file_externals_t *file_externals = |
| 616 | | | (dct2000_file_externals_t*)g_hash_table_lookup(file_externals_table, |
| 617 | | | ->dct2000.wth); |
| 618 | | | |
| 619 | | | if (wdh->dump.dct2000 == NULL) |
| 620 | | | { |
| 621 | | | |
| 622 | | | wdh->dump.dct2000 = g_malloc(sizeof(catapult_dct2000_t)); |
| 623 | | | |
| 624 | | | |
| 625 | | | if (! do_fwrite(file_externals->firstline, 1, file_externals->firstline_length, wdh->fh, err)) |
| 626 | | | { |
| 627 | | | return FALSE; |
| 628 | | | } |
| 629 | | | if (! do_fwrite("\n", 1, 1, wdh->fh, err)) |
| 630 | | | { |
| 631 | | | return FALSE; |
| 632 | | | } |
| 633 | | | |
| 634 | | | |
| 635 | | | |
| 636 | | | |
| 637 | | | if (! do_fwrite(file_externals->secondline, 1, file_externals->secondline_length, wdh->fh, err)) |
| 638 | | | { |
| 639 | | | return FALSE; |
| 640 | | | } |
| 641 | | | if (! do_fwrite("\n", 1, 1, wdh->fh, err)) |
| 642 | | | { |
| 643 | | | return FALSE; |
| 644 | | | } |
| 645 | | | |
| 646 | | | |
| 647 | | | wdh->dump.dct2000 = g_malloc(sizeof(catapult_dct2000_t)); |
| 648 | | | |
| 649 | | | |
| 650 | | | wdh->dump.dct2000->start_time.secs = |
| 651 | | | ->dct2000.wth->capture.catapult_dct2000->start_secs; |
| 652 | | | wdh->dump.dct2000->start_time.nsecs = |
| 653 | | | (->dct2000.wth->capture.catapult_dct2000->start_usecs * 1000); |
| 654 | | | |
| 655 | | | |
| 656 | | | wdh->dump.dct2000->first_packet_written = TRUE; |
| 657 | | | } |
| 658 | | | |
| 659 | | | |
| 660 | | | |
| 661 | | | |
| 662 | | | |
| 663 | | | |
| 664 | | | prefix = (line_prefix_info_t*)g_hash_table_lookup(file_externals->packet_prefix_table, |
| 665 | | | (const void*)&(->dct2000.seek_off)); |
| 666 | | | |
| 667 | | | |
| 668 | | | if (! do_fwrite(prefix->before_time, 1, strlen(prefix->before_time), wdh->fh, err)) |
| 669 | | | { |
| 670 | | | return FALSE; |
| 671 | | | } |
| 672 | | | |
| 673 | | | |
| 674 | | | if (phdr->ts.nsecs >= wdh->dump.dct2000->start_time.nsecs) |
| 675 | | | { |
| 676 | | | g_snprintf(time_string, 16, "%ld.%04d", |
| 677 | | | (long)(phdr->ts.secs - wdh->dump.dct2000->start_time.secs), |
| 678 | | | (phdr->ts.nsecs - wdh->dump.dct2000->start_time.nsecs) / 100000); |
| 679 | | | } |
| 680 | | | else |
| 681 | | | { |
| 682 | | | g_snprintf(time_string, 16, "%ld.%04u", |
| 683 | | | (long)(phdr->ts.secs - wdh->dump.dct2000->start_time.secs-1), |
| 684 | | | ((1000000000 + (phdr->ts.nsecs / 100000)) - (wdh->dump.dct2000->start_time.nsecs / 100000)) % 10000); |
| 685 | | | } |
| 686 | | | |
| 687 | | | |
| 688 | | | if (! do_fwrite(time_string, 1, strlen(time_string), wdh->fh, err)) |
| 689 | | | { |
| 690 | | | return FALSE; |
| 691 | | | } |
| 692 | | | |
| 693 | | | |
| 694 | | | if (prefix->after_time == NULL) |
| 695 | | | { |
| 696 | | | if (! do_fwrite(" l ", 1, strlen(" l "), wdh->fh, err)) |
| 697 | | | { |
| 698 | | | return FALSE; |
| 699 | | | } |
| 700 | | | } |
| 701 | | | else |
| 702 | | | { |
| 703 | | | if (! do_fwrite(prefix->after_time, 1, strlen(prefix->after_time), wdh->fh, err)) |
| 704 | | | { |
| 705 | | | return FALSE; |
| 706 | | | } |
| 707 | | | } |
| 708 | | | |
| 709 | | | |
| 710 | | | |
| 711 | | | |
| 712 | | | |
| 713 | | | |
| 714 | | | for (n=0; pd[n] != '\0'; n++); |
| 715 | | | n++; |
| 716 | | | |
| 717 | | | |
| 718 | | | n++; |
| 719 | | | |
| 720 | | | |
| 721 | | | for (; pd[n] != '\0'; n++); |
| 722 | | | n++; |
Unreachable Call
The highlighted code will not execute under any circumstances. This may be because of: |
|
| 723 | | | |
| 724 | | | |
| 725 | | | for (; pd[n] != '\0'; n++); |
| 726 | | | n++; |
| 727 | | | |
| 728 | | | |
| 729 | | | for (; pd[n] != '\0'; n++); |
| 730 | | | n++; |
| 731 | | | |
| 732 | | | |
| 733 | | | for (; pd[n] != '\0'; n++); |
| 734 | | | n++; |
| 735 | | | |
| 736 | | | |
| 737 | | | n += 2; |
| 738 | | | |
| 739 | | | |
| 740 | | | |
| 741 | | | |
| 742 | | | if (! do_fwrite("$", 1, 1, wdh->fh, err)) |
| 743 | | | { |
| 744 | | | return FALSE; |
| 745 | | | } |
| 746 | | | |
| 747 | | | |
| 748 | | | for (; n < phdr->len; n++) |
| 749 | | | { |
| 750 | | | gchar c[2]; |
| 751 | | | c[0] = char_from_hex((guchar)(pd[n] >> 4)); |
| 752 | | | c[1] = char_from_hex((guchar)(pd[n] & 0x0f)); |
| 753 | | | |
| 754 | | | |
| 755 | | | if (! do_fwrite(c, 1, 2, wdh->fh, err)) |
| 756 | | | { |
| 757 | | | return FALSE; |
| 758 | | | } |
| 759 | | | } |
| 760 | | | |
| 761 | | | |
| 762 | | | if (! do_fwrite("\n", 1, 1, wdh->fh, err)) |
| 763 | | | { |
| 764 | | | return FALSE; |
| 765 | | | } |
| 766 | | | |
| 767 | | | return TRUE; |
| 768 | | | } |
| |