(/home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/btsnoop.c) |
| |
| 83 | | | int btsnoop_open(wtap *wth, int *err, gchar **err_info _U_) |
| 84 | | | { |
| 85 | | | int bytes_read; |
| 86 | | | char magic[sizeof btsnoop_magic]; |
| 87 | | | struct btsnoop_hdr hdr; |
| 88 | | | |
| 89 | | | int file_encap=WTAP_ENCAP_UNKNOWN; |
| 90 | | | |
| 91 | | | |
| 92 | | | errno = WTAP_ERR_CANT_READ; |
| 93 | | | bytes_read = file_read(magic, 1, sizeof magic, wth->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))) |
| |
|
| 94 | | | if (bytes_read != sizeof magic) { |
| 95 | | | *err = file_error(wth->fh); |
| 96 | | | if (*err != 0) |
| 97 | | | return -1; |
| 98 | | | return 0; |
| 99 | | | } |
| 100 | | | wth->data_offset += sizeof magic; |
| 101 | | | |
| 102 | | | if (memcmp(magic, btsnoop_magic, sizeof btsnoop_magic) != 0) { |
| 103 | | | return 0; |
| 104 | | | } |
| 105 | | | |
| 106 | | | |
| 107 | | | errno = WTAP_ERR_CANT_READ; |
Useless Assignment
This code assigns the variable the same value it already had. |
|
| 108 | | | bytes_read = file_read(&hdr, 1, sizeof hdr, wth->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))) |
| |
|
| 109 | | | if (bytes_read != sizeof hdr) { |
| 110 | | | *err = file_error(wth->fh); |
| 111 | | | if (*err != 0) |
| 112 | | | return -1; |
| 113 | | | return 0; |
| 114 | | | } |
| 115 | | | wth->data_offset += sizeof hdr; |
| 116 | | | |
| 117 | | | |
| 118 | | | |
| 119 | | | |
| 120 | | | hdr.version = g_ntohl(hdr.version);
x /usr/include/glib-2.0/glib/gtypes.h |
| |
347 | #define g_ntohl(val) (GUINT32_FROM_BE (val)) |
| |
x /usr/include/glib-2.0/glib/gtypes.h |
| |
322 | #define GUINT32_FROM_BE(val) (GUINT32_TO_BE (val)) |
| |
x /usr/lib/i386-linux-gnu/glib-2.0/include/glibconfig.h |
| |
196 | #define GUINT32_TO_BE(val) (GUINT32_SWAP_LE_BE (val)) |
| |
x /usr/include/glib-2.0/glib/gtypes.h |
| |
229 | # define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_IA32 (val)) |
| |
x /usr/include/glib-2.0/glib/gtypes.h |
| |
203 | # define GUINT32_SWAP_LE_BE_IA32(val) \ |
204 | (__extension__ \ |
205 | ({ register guint32 __v, __x = ((guint32) (val)); \ |
206 | if (__builtin_constant_p (__x)) \ |
207 | __v = GUINT32_SWAP_LE_BE_CONSTANT (__x); \ |
208 | else \ |
209 | __asm__ ("bswap %0" \ |
210 | : "=r" (__v) \ |
211 | : "0" (__x)); \ |
212 | __v; })) |
| |
x /usr/include/glib-2.0/glib/gtypes.h |
| |
147 | #define GUINT32_SWAP_LE_BE_CONSTANT(val) ((guint32) ( \ |
148 | (((guint32) (val) & (guint32) 0x000000ffU) << 24) | \ |
149 | (((guint32) (val) & (guint32) 0x0000ff00U) << 8) | \ |
150 | (((guint32) (val) & (guint32) 0x00ff0000U) >> 8) | \ |
151 | (((guint32) (val) & (guint32) 0xff000000U) >> 24))) |
| |
|
| 121 | | | if (hdr.version != 1) { |
| 122 | | | *err = WTAP_ERR_UNSUPPORTED; |
| 123 | | | *err_info = g_strdup_printf("btsnoop: version %u unsupported", hdr.version); |
| 124 | | | return -1; |
| 125 | | | } |
| 126 | | | |
| 127 | | | hdr.datalink = g_ntohl(hdr.datalink);
x /usr/include/glib-2.0/glib/gtypes.h |
| |
347 | #define g_ntohl(val) (GUINT32_FROM_BE (val)) |
| |
x /usr/include/glib-2.0/glib/gtypes.h |
| |
322 | #define GUINT32_FROM_BE(val) (GUINT32_TO_BE (val)) |
| |
x /usr/lib/i386-linux-gnu/glib-2.0/include/glibconfig.h |
| |
196 | #define GUINT32_TO_BE(val) (GUINT32_SWAP_LE_BE (val)) |
| |
x /usr/include/glib-2.0/glib/gtypes.h |
| |
229 | # define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_IA32 (val)) |
| |
x /usr/include/glib-2.0/glib/gtypes.h |
| |
203 | # define GUINT32_SWAP_LE_BE_IA32(val) \ |
204 | (__extension__ \ |
205 | ({ register guint32 __v, __x = ((guint32) (val)); \ |
206 | if (__builtin_constant_p (__x)) \ |
207 | __v = GUINT32_SWAP_LE_BE_CONSTANT (__x); \ |
208 | else \ |
209 | __asm__ ("bswap %0" \ |
210 | : "=r" (__v) \ |
211 | : "0" (__x)); \ |
212 | __v; })) |
| |
x /usr/include/glib-2.0/glib/gtypes.h |
| |
147 | #define GUINT32_SWAP_LE_BE_CONSTANT(val) ((guint32) ( \ |
148 | (((guint32) (val) & (guint32) 0x000000ffU) << 24) | \ |
149 | (((guint32) (val) & (guint32) 0x0000ff00U) << 8) | \ |
150 | (((guint32) (val) & (guint32) 0x00ff0000U) >> 8) | \ |
151 | (((guint32) (val) & (guint32) 0xff000000U) >> 24))) |
| |
|
| 128 | | | switch (hdr.datalink) { |
| 129 | | | case KHciLoggerDatalinkTypeH1: |
| 130 | | | file_encap=WTAP_ENCAP_BLUETOOTH_HCI;
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/wtap.h |
| |
195 | #define WTAP_ENCAP_BLUETOOTH_HCI 102 /*raw packets without a transport layer e.g. H4*/ |
| |
|
| 131 | | | break; |
| 132 | | | case KHciLoggerDatalinkTypeBCSP: |
| 133 | | | case KHciLoggerDatalinkTypeH5: |
| 134 | | | *err = WTAP_ERR_UNSUPPORTED; |
| 135 | | | *err_info = g_strdup_printf("btsnoop: BCSP/H5 capture logs %u unsupported", hdr.version); |
| 136 | | | return -1; |
| 137 | | | case KHciLoggerDatalinkTypeH4: |
| 138 | | | file_encap=WTAP_ENCAP_BLUETOOTH_H4; |
| 139 | | | break; |
| 140 | | | default: |
| 141 | | | *err = WTAP_ERR_UNSUPPORTED; |
| 142 | | | *err_info = g_strdup_printf("btsnoop: datalink %u unsupported", hdr.version); |
| 143 | | | return -1; |
| 144 | | | } |
| 145 | | | |
| 146 | | | wth->subtype_read = btsnoop_read; |
| 147 | | | wth->subtype_seek_read = btsnoop_seek_read; |
| 148 | | | wth->file_encap = file_encap; |
| 149 | | | wth->snapshot_length = 0; |
| 150 | | | wth->tsprecision = WTAP_FILE_TSPREC_USEC; |
| 151 | | | wth->file_type = WTAP_FILE_BTSNOOP; |
| 152 | | | return 1; |
| 153 | | | } |
| |