(/home/sate/Testcases/c/cve/wireshark-1.2.0/text2pcap.c) |
| |
| 740 | | | parse_preamble (void) |
| 741 | | | { |
| 742 | | | struct tm timecode; |
| 743 | | | char *subsecs; |
| 744 | | | char *p; |
| 745 | | | int subseclen; |
| 746 | | | int i; |
| 747 | | | |
| 748 | | | |
| 749 | | | |
| 750 | | | |
| 751 | | | |
| 752 | | | if (ts_fmt == NULL) |
| 753 | | | return; |
| 754 | | | |
| 755 | | | |
| 756 | | | |
| 757 | | | |
| 758 | | | |
| 759 | | | |
| 760 | | | timecode = timecode_default; |
| 761 | | | ts_usec = 0; |
| 762 | | | |
| 763 | | | |
| 764 | | | |
| 765 | | | |
| 766 | | | packet_preamble[packet_preamble_len] = '\0'; |
| 767 | | | |
| 768 | | | |
| 769 | | | |
| 770 | | | |
| 771 | | | if ( strlen(packet_preamble) > 2 ) { |
| 772 | | | |
| 773 | | | subsecs = strptime( packet_preamble, ts_fmt, &timecode ); |
| 774 | | | if (subsecs != NULL) { |
| 775 | | | |
| 776 | | | |
| 777 | | | ts_sec = mktime( &timecode ); |
| 778 | | | } else |
| 779 | | | ts_sec = -1; |
| 780 | | | |
| 781 | | | |
| 782 | | | if ( -1 == ts_sec ) |
| 783 | | | { |
| 784 | | | |
| 785 | | | char *c; |
| 786 | | | while ((c = strchr(packet_preamble, '\r')) != NULL) *c=' '; |
| 787 | | | fprintf (stderr, "Failure processing time \"%s\" using time format \"%s\"\n (defaulting to Jan 1,1970 00:00:00 GMT)\n", |
| 788 | | | packet_preamble, ts_fmt); |
| 789 | | | if (debug >= 2) { |
| 790 | | | fprintf(stderr, "timecode: %02d/%02d/%d %02d:%02d:%02d %d\n", |
| 791 | | | timecode.tm_mday, timecode.tm_mon, timecode.tm_year, |
| 792 | | | timecode.tm_hour, timecode.tm_min, timecode.tm_sec, timecode.tm_isdst); |
| 793 | | | } |
| 794 | | | ts_sec = 0; |
| 795 | | | ts_usec = 0; |
Useless Assignment
This code assigns the variable the same value it already had. |
|
| 796 | | | } |
| 797 | | | else |
| 798 | | | { |
| 799 | | | |
| 800 | | | ts_usec = strtol(subsecs, &p, 10); |
| 801 | | | if (subsecs == p) { |
| 802 | | | |
| 803 | | | ts_usec = 0; |
| 804 | | | } else { |
| 805 | | | |
| 806 | | | |
| 807 | | | |
| 808 | | | |
| 809 | | | |
| 810 | | | |
| 811 | | | |
| 812 | | | |
| 813 | | | subseclen = (int) (p - subsecs); |
| 814 | | | if (subseclen > 6) { |
| 815 | | | |
| 816 | | | |
| 817 | | | |
| 818 | | | |
| 819 | | | |
| 820 | | | for (i = subseclen - 6; i != 0; i--) |
| 821 | | | ts_usec /= 10; |
| 822 | | | } else if (subseclen < 6) { |
| 823 | | | for (i = 6 - subseclen; i != 0; i--) |
| 824 | | | ts_usec *= 10; |
| 825 | | | } |
| 826 | | | } |
| 827 | | | } |
| 828 | | | } |
| 829 | | | if (debug >= 2) { |
| 830 | | | char *c; |
| 831 | | | while ((c = strchr(packet_preamble, '\r')) != NULL) *c=' '; |
| 832 | | | fprintf(stderr, "[[parse_preamble: \"%s\"]]\n", packet_preamble); |
| 833 | | | fprintf(stderr, "Format(%s), time(%u), subsecs(%u)\n", ts_fmt, (guint32)ts_sec, ts_usec); |
| 834 | | | } |
| 835 | | | |
| 836 | | | |
| 837 | | | |
| 838 | | | packet_preamble_len = 0; |
| 839 | | | } |
| |