(/home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/visual.c) |
| |
| 180 | | | int visual_open(wtap *wth, int *err, gchar **err_info) |
| 181 | | | { |
| 182 | | | int bytes_read; |
| 183 | | | char magic[sizeof visual_magic]; |
| 184 | | | struct visual_file_hdr vfile_hdr; |
| 185 | | | struct visual_read_info * visual; |
| 186 | | | int encap; |
| 187 | | | |
| 188 | | | |
| 189 | | | errno = WTAP_ERR_CANT_READ; |
| 190 | | | 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))) |
| |
|
| 191 | | | if (bytes_read != sizeof magic) |
| 192 | | | { |
| 193 | | | *err = file_error(wth->fh); |
| 194 | | | if (*err != 0) |
| 195 | | | return -1; |
| 196 | | | return 0; |
| 197 | | | } |
| 198 | | | if (memcmp(magic, visual_magic, sizeof visual_magic) != 0) |
| 199 | | | { |
| 200 | | | return 0; |
| 201 | | | } |
| 202 | | | |
| 203 | | | |
| 204 | | | errno = WTAP_ERR_CANT_READ; |
Useless Assignment
This code assigns the variable the same value it already had. |
|
| 205 | | | bytes_read = file_read(&vfile_hdr, 1, sizeof vfile_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))) |
| |
|
| 206 | | | if (bytes_read != sizeof vfile_hdr) |
| 207 | | | { |
| 208 | | | *err = file_error(wth->fh); |
| 209 | | | if (*err != 0) |
| 210 | | | return -1; |
| 211 | | | return 0; |
| 212 | | | } |
| 213 | | | |
| 214 | | | |
| 215 | | | vfile_hdr.file_version = pletohs(&vfile_hdr.file_version);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/wtap-int.h |
| |
373 | #define pletohs(p) ((guint16) \ |
374 | ((guint16)*((const guint8 *)(p)+1)<<8| \ |
375 | (guint16)*((const guint8 *)(p)+0)<<0)) |
| |
|
| 216 | | | if (vfile_hdr.file_version != 1) |
| 217 | | | { |
| 218 | | | *err = WTAP_ERR_UNSUPPORTED; |
| 219 | | | *err_info = g_strdup_printf("visual: file version %u unsupported", vfile_hdr.file_version); |
| 220 | | | return -1; |
| 221 | | | } |
| 222 | | | |
| 223 | | | |
| 224 | | | |
| 225 | | | |
| 226 | | | |
| 227 | | | |
| 228 | | | |
| 229 | | | |
| 230 | | | |
| 231 | | | switch (pletohs(&vfile_hdr.media_type))
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/wtap-int.h |
| |
373 | #define pletohs(p) ((guint16) \ |
374 | ((guint16)*((const guint8 *)(p)+1)<<8| \ |
375 | (guint16)*((const guint8 *)(p)+0)<<0)) |
| |
|
| 232 | | | { |
| 233 | | | case 6: |
| 234 | | | encap = WTAP_ENCAP_ETHERNET; |
| 235 | | | break; |
| 236 | | | |
| 237 | | | case 9: |
| 238 | | | encap = WTAP_ENCAP_TOKEN_RING; |
| 239 | | | break; |
| 240 | | | |
| 241 | | | case 16: |
| 242 | | | encap = WTAP_ENCAP_LAPB; |
| 243 | | | break; |
| 244 | | | |
| 245 | | | case 22: |
| 246 | | | case 118: |
| 247 | | | encap = WTAP_ENCAP_CHDLC_WITH_PHDR; |
| 248 | | | break; |
| 249 | | | |
| 250 | | | case 32: |
| 251 | | | encap = WTAP_ENCAP_FRELAY_WITH_PHDR; |
| 252 | | | break; |
| 253 | | | |
| 254 | | | case 37: |
| 255 | | | encap = WTAP_ENCAP_ATM_PDUS; |
| 256 | | | break; |
| 257 | | | |
| 258 | | | default: |
| 259 | | | *err = WTAP_ERR_UNSUPPORTED_ENCAP; |
| 260 | | | *err_info = g_strdup_printf("visual: network type %u unknown or unsupported", |
| 261 | | | vfile_hdr.media_type); |
| 262 | | | return -1; |
| 263 | | | } |
| 264 | | | |
| 265 | | | |
| 266 | | | wth->file_type = WTAP_FILE_VISUAL_NETWORKS; |
| 267 | | | wth->file_encap = encap; |
| 268 | | | wth->snapshot_length = pletohs(&vfile_hdr.max_length);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/wtap-int.h |
| |
373 | #define pletohs(p) ((guint16) \ |
374 | ((guint16)*((const guint8 *)(p)+1)<<8| \ |
375 | (guint16)*((const guint8 *)(p)+0)<<0)) |
| |
|
| 269 | | | |
| 270 | | | |
| 271 | | | |
| 272 | | | wth->data_offset = ; |
| 273 | | | |
| 274 | | | |
| 275 | | | wth->subtype_read = visual_read; |
| 276 | | | wth->subtype_seek_read = visual_seek_read; |
| 277 | | | wth->subtype_close = visual_close; |
| 278 | | | wth->tsprecision = WTAP_FILE_TSPREC_USEC; |
| 279 | | | |
| 280 | | | |
| 281 | | | visual = g_malloc(sizeof(struct visual_read_info)); |
| 282 | | | wth->capture.generic = visual; |
| 283 | | | visual->num_pkts = pletohl(&vfile_hdr.num_pkts);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/wtap-int.h |
| |
386 | #define pletohl(p) ((guint32)*((const guint8 *)(p)+3)<<24| \ |
387 | (guint32)*((const guint8 *)(p)+2)<<16| \ |
388 | (guint32)*((const guint8 *)(p)+1)<<8| \ |
389 | (guint32)*((const guint8 *)(p)+0)<<0) |
| |
|
| 284 | | | visual->start_time = ((double) pletohl(&vfile_hdr.start_time)) * 1000000;
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/wtap-int.h |
| |
386 | #define pletohl(p) ((guint32)*((const guint8 *)(p)+3)<<24| \ |
387 | (guint32)*((const guint8 *)(p)+2)<<16| \ |
388 | (guint32)*((const guint8 *)(p)+1)<<8| \ |
389 | (guint32)*((const guint8 *)(p)+0)<<0) |
| |
|
| 285 | | | visual->current_pkt = 1; |
| 286 | | | |
| 287 | | | return 1; |
| 288 | | | } |
| |