(/home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/pcapng.c) |
| |
| 891 | | | pcapng_read_interface_statistics_block(FILE_T fh, *bh, pcapng_t *pn, wtapng_block_t *wblock,int *err, gchar **err_info _U_) |
| 892 | | | { |
| 893 | | | int bytes_read; |
| 894 | | | int block_read; |
| 895 | | | int to_read; |
| 896 | | | pcapng_interface_statistics_block_t isb; |
| 897 | | | oh; |
| 898 | | | char option_content[100]; |
| 899 | | | |
| 900 | | | |
| 901 | | | |
| 902 | | | errno = WTAP_ERR_CANT_READ; |
| 903 | | | bytes_read = file_read(&isb, 1, sizeof isb, 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))) |
| |
|
| 904 | | | if (bytes_read != sizeof isb) { |
| 905 | | | pcapng_debug0("pcapng_read_interface_statistics_block: failed to read packet data"); |
| 906 | | | *err = file_error(fh); |
| 907 | | | return 0; |
| 908 | | | } |
| 909 | | | block_read = bytes_read; |
| 910 | | | |
| 911 | | | if(pn->byte_swapped) { |
| 912 | | | wblock->data.if_stats.interface_id = BSWAP64(isb.interface_id);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/wtap-int.h |
| |
288 | #define BSWAP64(x) \ |
289 | ((((x)&G_GINT64_CONSTANT(0xFF00000000000000U))>>56) | \ |
290 | (((x)&G_GINT64_CONSTANT(0x00FF000000000000U))>>40) | \ |
291 | (((x)&G_GINT64_CONSTANT(0x0000FF0000000000U))>>24) | \ |
292 | (((x)&G_GINT64_CONSTANT(0x000000FF00000000U))>>8) | \ |
293 | (((x)&G_GINT64_CONSTANT(0x00000000FF000000U))<<8) | \ |
294 | (((x)&G_GINT64_CONSTANT(0x0000000000FF0000U))<<24) | \ |
295 | (((x)&G_GINT64_CONSTANT(0x000000000000FF00U))<<40) | \ |
296 | (((x)&G_GINT64_CONSTANT(0x00000000000000FFU))<<56)) |
| |
x /usr/lib/i386-linux-gnu/glib-2.0/include/glibconfig.h |
| |
55 | #define G_GINT64_CONSTANT(val) (G_GNUC_EXTENSION (val##LL)) |
| |
x /usr/include/glib-2.0/glib/gmacros.h |
| |
47 | # define G_GNUC_EXTENSION __extension__ |
| |
x /usr/lib/i386-linux-gnu/glib-2.0/include/glibconfig.h |
| |
55 | #define G_GINT64_CONSTANT(val) (G_GNUC_EXTENSION (val##LL)) |
| |
x /usr/include/glib-2.0/glib/gmacros.h |
| |
47 | # define G_GNUC_EXTENSION __extension__ |
| |
x /usr/lib/i386-linux-gnu/glib-2.0/include/glibconfig.h |
| |
55 | #define G_GINT64_CONSTANT(val) (G_GNUC_EXTENSION (val##LL)) |
| |
x /usr/include/glib-2.0/glib/gmacros.h |
| |
47 | # define G_GNUC_EXTENSION __extension__ |
| |
x /usr/lib/i386-linux-gnu/glib-2.0/include/glibconfig.h |
| |
55 | #define G_GINT64_CONSTANT(val) (G_GNUC_EXTENSION (val##LL)) |
| |
x /usr/include/glib-2.0/glib/gmacros.h |
| |
47 | # define G_GNUC_EXTENSION __extension__ |
| |
x /usr/lib/i386-linux-gnu/glib-2.0/include/glibconfig.h |
| |
55 | #define G_GINT64_CONSTANT(val) (G_GNUC_EXTENSION (val##LL)) |
| |
x /usr/include/glib-2.0/glib/gmacros.h |
| |
47 | # define G_GNUC_EXTENSION __extension__ |
| |
x /usr/lib/i386-linux-gnu/glib-2.0/include/glibconfig.h |
| |
55 | #define G_GINT64_CONSTANT(val) (G_GNUC_EXTENSION (val##LL)) |
| |
x /usr/include/glib-2.0/glib/gmacros.h |
| |
47 | # define G_GNUC_EXTENSION __extension__ |
| |
x /usr/lib/i386-linux-gnu/glib-2.0/include/glibconfig.h |
| |
55 | #define G_GINT64_CONSTANT(val) (G_GNUC_EXTENSION (val##LL)) |
| |
x /usr/include/glib-2.0/glib/gmacros.h |
| |
47 | # define G_GNUC_EXTENSION __extension__ |
| |
x /usr/lib/i386-linux-gnu/glib-2.0/include/glibconfig.h |
| |
55 | #define G_GINT64_CONSTANT(val) (G_GNUC_EXTENSION (val##LL)) |
| |
x /usr/include/glib-2.0/glib/gmacros.h |
| |
47 | # define G_GNUC_EXTENSION __extension__ |
| |
|
| 913 | | | wblock->data.if_stats.ts_high = BSWAP32(isb.timestamp_high);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/wtap-int.h |
| |
297 | #define BSWAP32(x) \ |
298 | ((((x)&0xFF000000)>>24) | \ |
299 | (((x)&0x00FF0000)>>8) | \ |
300 | (((x)&0x0000FF00)<<8) | \ |
301 | (((x)&0x000000FF)<<24)) |
| |
|
| 914 | | | wblock->data.if_stats.ts_low = BSWAP32(isb.timestamp_low);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/wtap-int.h |
| |
297 | #define BSWAP32(x) \ |
298 | ((((x)&0xFF000000)>>24) | \ |
299 | (((x)&0x00FF0000)>>8) | \ |
300 | (((x)&0x0000FF00)<<8) | \ |
301 | (((x)&0x000000FF)<<24)) |
| |
|
| 915 | | | } else { |
| 916 | | | wblock->data.if_stats.interface_id = isb.interface_id; |
| 917 | | | wblock->data.if_stats.ts_high = isb.timestamp_high; |
| 918 | | | wblock->data.if_stats.ts_low = isb.timestamp_low; |
| 919 | | | } |
| 920 | | | pcapng_debug1("pcapng_read_interface_statistics_block: interface_id %" G_GINT64_MODIFIER "u", wblock->data.if_stats.interface_id); |
| 921 | | | |
| 922 | | | |
| 923 | | | wblock->data.if_stats. = NULL; |
| 924 | | | wblock->data.if_stats.isb_ifrecv = -1; |
| 925 | | | wblock->data.if_stats.isb_ifdrop = -1; |
| 926 | | | |
| 927 | | | |
| 928 | | | errno = WTAP_ERR_CANT_READ; |
Useless Assignment
This code assigns the variable the same value it already had. |
|
| 929 | | | to_read = bh->block_total_length |
| 930 | | | - sizeof() |
| 931 | | | - block_read |
| 932 | | | - sizeof(bh->block_total_length); |
| 933 | | | while(to_read > 0) { |
| 934 | | | |
| 935 | | | bytes_read = pcapng_read_option(fh, pn, &oh, option_content, sizeof(option_content), err, err_info); |
| 936 | | | if (bytes_read <= 0) { |
| 937 | | | pcapng_debug0("pcapng_read_interface_statistics_block: failed to read option"); |
| 938 | | | return bytes_read; |
| 939 | | | } |
| 940 | | | block_read += bytes_read; |
| 941 | | | to_read -= bytes_read; |
| 942 | | | |
| 943 | | | |
| 944 | | | switch(oh.option_code) { |
| 945 | | | case(0): |
| 946 | | | if(to_read != 0) { |
| 947 | | | pcapng_debug1("pcapng_read_interface_statistics_block: %u bytes after opt_endofopt", to_read); |
| 948 | | | } |
| 949 | | | |
| 950 | | | to_read = 0; |
| 951 | | | break; |
| 952 | | | case(1): |
| 953 | | | if(oh.option_length > 0 && oh.option_length < sizeof(option_content)) { |
| 954 | | | wblock->data.section. = g_strndup(option_content, sizeof(option_content)); |
| 955 | | | pcapng_debug1("pcapng_read_interface_statistics_block: %s", wblock->data.section.); |
| 956 | | | } else { |
| 957 | | | pcapng_debug1("pcapng_read_interface_statistics_block: length %u seems strange", oh.option_length); |
| 958 | | | } |
| 959 | | | break; |
| 960 | | | case(4): |
| 961 | | | if(oh.option_length == 8) { |
| 962 | | | |
| 963 | | | |
| 964 | | | |
| 965 | | | memcpy(&wblock->data.if_stats.isb_ifrecv, option_content, sizeof(guint64)); |
| 966 | | | if(pn->byte_swapped) |
| 967 | | | wblock->data.if_stats.isb_ifrecv = BSWAP64(wblock->data.if_stats.isb_ifrecv);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/wtap-int.h |
| |
288 | #define BSWAP64(x) \ |
289 | ((((x)&G_GINT64_CONSTANT(0xFF00000000000000U))>>56) | \ |
290 | (((x)&G_GINT64_CONSTANT(0x00FF000000000000U))>>40) | \ |
291 | (((x)&G_GINT64_CONSTANT(0x0000FF0000000000U))>>24) | \ |
292 | (((x)&G_GINT64_CONSTANT(0x000000FF00000000U))>>8) | \ |
293 | (((x)&G_GINT64_CONSTANT(0x00000000FF000000U))<<8) | \ |
294 | (((x)&G_GINT64_CONSTANT(0x0000000000FF0000U))<<24) | \ |
295 | (((x)&G_GINT64_CONSTANT(0x000000000000FF00U))<<40) | \ |
296 | (((x)&G_GINT64_CONSTANT(0x00000000000000FFU))<<56)) |
| |
x /usr/lib/i386-linux-gnu/glib-2.0/include/glibconfig.h |
| |
55 | #define G_GINT64_CONSTANT(val) (G_GNUC_EXTENSION (val##LL)) |
| |
x /usr/include/glib-2.0/glib/gmacros.h |
| |
47 | # define G_GNUC_EXTENSION __extension__ |
| |
x /usr/lib/i386-linux-gnu/glib-2.0/include/glibconfig.h |
| |
55 | #define G_GINT64_CONSTANT(val) (G_GNUC_EXTENSION (val##LL)) |
| |
x /usr/include/glib-2.0/glib/gmacros.h |
| |
47 | # define G_GNUC_EXTENSION __extension__ |
| |
x /usr/lib/i386-linux-gnu/glib-2.0/include/glibconfig.h |
| |
55 | #define G_GINT64_CONSTANT(val) (G_GNUC_EXTENSION (val##LL)) |
| |
x /usr/include/glib-2.0/glib/gmacros.h |
| |
47 | # define G_GNUC_EXTENSION __extension__ |
| |
x /usr/lib/i386-linux-gnu/glib-2.0/include/glibconfig.h |
| |
55 | #define G_GINT64_CONSTANT(val) (G_GNUC_EXTENSION (val##LL)) |
| |
x /usr/include/glib-2.0/glib/gmacros.h |
| |
47 | # define G_GNUC_EXTENSION __extension__ |
| |
x /usr/lib/i386-linux-gnu/glib-2.0/include/glibconfig.h |
| |
55 | #define G_GINT64_CONSTANT(val) (G_GNUC_EXTENSION (val##LL)) |
| |
x /usr/include/glib-2.0/glib/gmacros.h |
| |
47 | # define G_GNUC_EXTENSION __extension__ |
| |
x /usr/lib/i386-linux-gnu/glib-2.0/include/glibconfig.h |
| |
55 | #define G_GINT64_CONSTANT(val) (G_GNUC_EXTENSION (val##LL)) |
| |
x /usr/include/glib-2.0/glib/gmacros.h |
| |
47 | # define G_GNUC_EXTENSION __extension__ |
| |
x /usr/lib/i386-linux-gnu/glib-2.0/include/glibconfig.h |
| |
55 | #define G_GINT64_CONSTANT(val) (G_GNUC_EXTENSION (val##LL)) |
| |
x /usr/include/glib-2.0/glib/gmacros.h |
| |
47 | # define G_GNUC_EXTENSION __extension__ |
| |
x /usr/lib/i386-linux-gnu/glib-2.0/include/glibconfig.h |
| |
55 | #define G_GINT64_CONSTANT(val) (G_GNUC_EXTENSION (val##LL)) |
| |
x /usr/include/glib-2.0/glib/gmacros.h |
| |
47 | # define G_GNUC_EXTENSION __extension__ |
| |
|
| 968 | | | pcapng_debug1("pcapng_read_interface_statistics_block: isb_ifrecv %" G_GINT64_MODIFIER "u", wblock->data.if_stats.isb_ifrecv); |
| 969 | | | } else { |
| 970 | | | pcapng_debug1("pcapng_read_interface_statistics_block: isb_ifrecv length %u not 8 as expected", oh.option_length); |
| 971 | | | } |
| 972 | | | break; |
| 973 | | | case(5): |
| 974 | | | if(oh.option_length == 8) { |
| 975 | | | |
| 976 | | | |
| 977 | | | |
| 978 | | | memcpy(&wblock->data.if_stats.isb_ifdrop, option_content, sizeof(guint64)); |
| 979 | | | if(pn->byte_swapped) |
| 980 | | | wblock->data.if_stats.isb_ifdrop = BSWAP64(wblock->data.if_stats.isb_ifdrop);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/wtap-int.h |
| |
288 | #define BSWAP64(x) \ |
289 | ((((x)&G_GINT64_CONSTANT(0xFF00000000000000U))>>56) | \ |
290 | (((x)&G_GINT64_CONSTANT(0x00FF000000000000U))>>40) | \ |
291 | (((x)&G_GINT64_CONSTANT(0x0000FF0000000000U))>>24) | \ |
292 | (((x)&G_GINT64_CONSTANT(0x000000FF00000000U))>>8) | \ |
293 | (((x)&G_GINT64_CONSTANT(0x00000000FF000000U))<<8) | \ |
294 | (((x)&G_GINT64_CONSTANT(0x0000000000FF0000U))<<24) | \ |
295 | (((x)&G_GINT64_CONSTANT(0x000000000000FF00U))<<40) | \ |
296 | (((x)&G_GINT64_CONSTANT(0x00000000000000FFU))<<56)) |
| |
x /usr/lib/i386-linux-gnu/glib-2.0/include/glibconfig.h |
| |
55 | #define G_GINT64_CONSTANT(val) (G_GNUC_EXTENSION (val##LL)) |
| |
x /usr/include/glib-2.0/glib/gmacros.h |
| |
47 | # define G_GNUC_EXTENSION __extension__ |
| |
x /usr/lib/i386-linux-gnu/glib-2.0/include/glibconfig.h |
| |
55 | #define G_GINT64_CONSTANT(val) (G_GNUC_EXTENSION (val##LL)) |
| |
x /usr/include/glib-2.0/glib/gmacros.h |
| |
47 | # define G_GNUC_EXTENSION __extension__ |
| |
x /usr/lib/i386-linux-gnu/glib-2.0/include/glibconfig.h |
| |
55 | #define G_GINT64_CONSTANT(val) (G_GNUC_EXTENSION (val##LL)) |
| |
x /usr/include/glib-2.0/glib/gmacros.h |
| |
47 | # define G_GNUC_EXTENSION __extension__ |
| |
x /usr/lib/i386-linux-gnu/glib-2.0/include/glibconfig.h |
| |
55 | #define G_GINT64_CONSTANT(val) (G_GNUC_EXTENSION (val##LL)) |
| |
x /usr/include/glib-2.0/glib/gmacros.h |
| |
47 | # define G_GNUC_EXTENSION __extension__ |
| |
x /usr/lib/i386-linux-gnu/glib-2.0/include/glibconfig.h |
| |
55 | #define G_GINT64_CONSTANT(val) (G_GNUC_EXTENSION (val##LL)) |
| |
x /usr/include/glib-2.0/glib/gmacros.h |
| |
47 | # define G_GNUC_EXTENSION __extension__ |
| |
x /usr/lib/i386-linux-gnu/glib-2.0/include/glibconfig.h |
| |
55 | #define G_GINT64_CONSTANT(val) (G_GNUC_EXTENSION (val##LL)) |
| |
x /usr/include/glib-2.0/glib/gmacros.h |
| |
47 | # define G_GNUC_EXTENSION __extension__ |
| |
x /usr/lib/i386-linux-gnu/glib-2.0/include/glibconfig.h |
| |
55 | #define G_GINT64_CONSTANT(val) (G_GNUC_EXTENSION (val##LL)) |
| |
x /usr/include/glib-2.0/glib/gmacros.h |
| |
47 | # define G_GNUC_EXTENSION __extension__ |
| |
x /usr/lib/i386-linux-gnu/glib-2.0/include/glibconfig.h |
| |
55 | #define G_GINT64_CONSTANT(val) (G_GNUC_EXTENSION (val##LL)) |
| |
x /usr/include/glib-2.0/glib/gmacros.h |
| |
47 | # define G_GNUC_EXTENSION __extension__ |
| |
|
| 981 | | | pcapng_debug1("pcapng_read_interface_statistics_block: isb_ifdrop %" G_GINT64_MODIFIER "u", wblock->data.if_stats.isb_ifdrop); |
| 982 | | | } else { |
| 983 | | | pcapng_debug1("pcapng_read_interface_statistics_block: isb_ifdrop length %u not 8 as expected", oh.option_length); |
| 984 | | | } |
| 985 | | | break; |
| 986 | | | default: |
| 987 | | | pcapng_debug2("pcapng_read_interface_statistics_block: unknown option %u - ignoring %u bytes", |
| 988 | | | oh.option_code, oh.option_length); |
| 989 | | | } |
| 990 | | | } |
| 991 | | | |
| 992 | | | return block_read; |
| 993 | | | } |
| |