(/home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/libpcap.c) |
| |
| 983 | | | static gboolean libpcap_dump(wtap_dumper *wdh, |
| 984 | | | const struct wtap_pkthdr *phdr, |
| 985 | | | const union *, |
| 986 | | | const guchar *pd, int *err) |
| 987 | | | { |
| 988 | | | struct pcaprec_ss990915_hdr rec_hdr; |
| 989 | | | size_t hdr_size; |
| 990 | | | size_t nwritten; |
| 991 | | | int phdrsize; |
| 992 | | | |
| 993 | | | phdrsize = pcap_get_phdr_size(wdh->encap, ); |
| 994 | | | |
| 995 | | | rec_hdr.hdr.ts_sec = (guint32) phdr->ts.secs; |
| 996 | | | if(wdh->tsprecision == WTAP_FILE_TSPREC_NSEC) { |
| 997 | | | rec_hdr.hdr.ts_usec = phdr->ts.nsecs; |
| 998 | | | } else { |
| 999 | | | rec_hdr.hdr.ts_usec = phdr->ts.nsecs / 1000; |
| 1000 | | | } |
| 1001 | | | rec_hdr.hdr.incl_len = phdr->caplen + phdrsize; |
| 1002 | | | rec_hdr.hdr.orig_len = phdr->len + phdrsize; |
| 1003 | | | switch (wdh->file_type) { |
| 1004 | | | |
| 1005 | | | case WTAP_FILE_PCAP: |
| 1006 | | | case WTAP_FILE_PCAP_NSEC: |
| 1007 | | | hdr_size = sizeof (struct pcaprec_hdr); |
| 1008 | | | break; |
| 1009 | | | |
| 1010 | | | case WTAP_FILE_PCAP_SS990417: |
| 1011 | | | case WTAP_FILE_PCAP_SS991029: |
| 1012 | | | |
| 1013 | | | |
| 1014 | | | |
| 1015 | | | |
| 1016 | | | |
| 1017 | | | |
| 1018 | | | |
| 1019 | | | |
| 1020 | | | |
| 1021 | | | |
| 1022 | | | |
| 1023 | | | |
| 1024 | | | |
| 1025 | | | |
| 1026 | | | |
| 1027 | | | |
| 1028 | | | |
| 1029 | | | |
| 1030 | | | |
| 1031 | | | rec_hdr.ifindex = 0; |
| 1032 | | | rec_hdr.protocol = 0; |
| 1033 | | | rec_hdr.pkt_type = 0; |
| 1034 | | | hdr_size = sizeof (struct pcaprec_modified_hdr); |
| 1035 | | | break; |
| 1036 | | | |
| 1037 | | | case WTAP_FILE_PCAP_SS990915: |
| 1038 | | | rec_hdr.ifindex = 0; |
| 1039 | | | rec_hdr.protocol = 0; |
| 1040 | | | rec_hdr.pkt_type = 0; |
| 1041 | | | rec_hdr.cpu1 = 0; |
| 1042 | | | rec_hdr.cpu2 = 0; |
| 1043 | | | hdr_size = sizeof (struct pcaprec_ss990915_hdr); |
| 1044 | | | break; |
| 1045 | | | |
| 1046 | | | case WTAP_FILE_PCAP_NOKIA: |
| 1047 | | | rec_hdr.ifindex = 0; |
| 1048 | | | rec_hdr.protocol = 0; |
| 1049 | | | rec_hdr.pkt_type = 0; |
| 1050 | | | rec_hdr.cpu1 = 0; |
| 1051 | | | rec_hdr.cpu2 = 0; |
| 1052 | | | hdr_size = sizeof (struct pcaprec_nokia_hdr); |
| 1053 | | | break; |
| 1054 | | | |
| 1055 | | | default: |
| 1056 | | | |
| 1057 | | | |
| 1058 | | | g_assert_not_reached();
x /usr/include/glib-2.0/glib/gtestutils.h |
| |
73 | #define g_assert_not_reached() do { g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, NULL); } while (0) |
| |
x /usr/include/glib-2.0/glib/gmacros.h |
| |
160 | # define G_STRFUNC ((const char*) (__PRETTY_FUNCTION__)) |
| |
|
| 1059 | | | *err = WTAP_ERR_UNSUPPORTED_FILE_TYPE; |
Unreachable Computation
The highlighted code will not execute under any circumstances. This may be because of: |
|
| 1060 | | | return FALSE; |
| 1061 | | | } |
| 1062 | | | |
| 1063 | | | nwritten = wtap_dump_file_write(wdh, &rec_hdr, hdr_size); |
| 1064 | | | if (nwritten != hdr_size) { |
| 1065 | | | if (nwritten == 0 && wtap_dump_file_ferror(wdh)) |
| 1066 | | | *err = wtap_dump_file_ferror(wdh); |
| 1067 | | | else |
| 1068 | | | *err = WTAP_ERR_SHORT_WRITE; |
| 1069 | | | return FALSE; |
| 1070 | | | } |
| 1071 | | | wdh->bytes_dumped += hdr_size; |
| 1072 | | | |
| 1073 | | | if (!pcap_write_phdr(wdh, , err)) |
| 1074 | | | return FALSE; |
| 1075 | | | |
| 1076 | | | nwritten = wtap_dump_file_write(wdh, pd, phdr->caplen); |
| 1077 | | | if (nwritten != phdr->caplen) { |
| 1078 | | | if (nwritten == 0 && wtap_dump_file_ferror(wdh)) |
| 1079 | | | *err = wtap_dump_file_ferror(wdh); |
| 1080 | | | else |
| 1081 | | | *err = WTAP_ERR_SHORT_WRITE; |
| 1082 | | | return FALSE; |
| 1083 | | | } |
| 1084 | | | wdh->bytes_dumped += phdr->caplen; |
| 1085 | | | return TRUE; |
| 1086 | | | } |
| |