(/home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/visual.c) |
| |
| 295 | | | static gboolean visual_read(wtap *wth, int *err, gchar **err_info, |
| 296 | | | gint64 *data_offset) |
| 297 | | | { |
| 298 | | | struct visual_read_info *visual = wth->capture.generic; |
| 299 | | | guint32 packet_size = 0; |
| 300 | | | int bytes_read; |
| 301 | | | struct visual_pkt_hdr vpkt_hdr; |
| 302 | | | struct visual_atm_hdr vatm_hdr; |
| 303 | | | int phdr_size = sizeof(vpkt_hdr); |
| 304 | | | int ahdr_size = sizeof(vatm_hdr); |
| 305 | | | time_t secs; |
| 306 | | | guint32 usecs; |
| 307 | | | double t; |
| 308 | | | |
| 309 | | | |
| 310 | | | |
| 311 | | | |
| 312 | | | if (visual->current_pkt > visual->num_pkts) |
| 313 | | | { |
| 314 | | | *err = 0; |
| 315 | | | return FALSE; |
| 316 | | | } |
| 317 | | | visual->current_pkt++; |
| 318 | | | |
| 319 | | | |
| 320 | | | errno = WTAP_ERR_CANT_READ; |
| 321 | | | bytes_read = file_read(&vpkt_hdr, 1, phdr_size, 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))) |
| |
|
| 322 | | | if (bytes_read != phdr_size) |
| 323 | | | { |
| 324 | | | *err = file_error(wth->fh); |
| 325 | | | if (*err == 0 && bytes_read != 0) |
| 326 | | | { |
| 327 | | | *err = WTAP_ERR_SHORT_READ; |
| 328 | | | } |
| 329 | | | return FALSE; |
| 330 | | | } |
| 331 | | | wth->data_offset += phdr_size; |
| 332 | | | |
| 333 | | | |
| 334 | | | packet_size = pletohs(&vpkt_hdr.incl_len);
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)) |
| |
|
| 335 | | | |
| 336 | | | |
| 337 | | | if (wth->file_encap == WTAP_ENCAP_ATM_PDUS) |
| 338 | | | { |
| 339 | | | |
| 340 | | | errno = WTAP_ERR_CANT_READ; |
| 341 | | | bytes_read = file_read(&vatm_hdr, 1, ahdr_size, 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))) |
| |
|
| 342 | | | if (bytes_read != ahdr_size) |
| 343 | | | { |
| 344 | | | *err = file_error(wth->fh); |
| 345 | | | if (*err == 0 && bytes_read != 0) |
| 346 | | | { |
| 347 | | | *err = WTAP_ERR_SHORT_READ; |
| 348 | | | } |
| 349 | | | return FALSE; |
| 350 | | | } |
| 351 | | | wth->data_offset += ahdr_size; |
| 352 | | | |
| 353 | | | |
| 354 | | | |
| 355 | | | |
| 356 | | | packet_size -= ahdr_size; |
| 357 | | | } |
| 358 | | | |
| 359 | | | |
| 360 | | | if (packet_size > WTAP_MAX_PACKET_SIZE) |
| 361 | | | { |
| 362 | | | |
| 363 | | | |
| 364 | | | *err = WTAP_ERR_BAD_RECORD; |
| 365 | | | *err_info = g_strdup_printf("visual: File has %u-byte packet, bigger than maximum of %u", |
| 366 | | | packet_size, WTAP_MAX_PACKET_SIZE); |
| 367 | | | return FALSE; |
| 368 | | | } |
| 369 | | | buffer_assure_space(wth->frame_buffer, packet_size); |
| 370 | | | *data_offset = wth->data_offset; |
| 371 | | | errno = WTAP_ERR_CANT_READ; |
Useless Assignment
This code assigns the variable the same value it already had. |
|
| 372 | | | bytes_read = file_read(buffer_start_ptr(wth->frame_buffer), 1,
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))) |
| |
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/buffer.h |
| |
46 | # define buffer_start_ptr(buffer) ((buffer)->data + (buffer)->start) |
| |
|
| 373 | | | packet_size, wth->fh); |
| 374 | | | |
| 375 | | | if (bytes_read != (int) packet_size) |
| 376 | | | { |
| 377 | | | *err = file_error(wth->fh); |
| 378 | | | if (*err == 0) |
| 379 | | | *err = WTAP_ERR_SHORT_READ; |
| 380 | | | return FALSE; |
| 381 | | | } |
| 382 | | | wth->data_offset += packet_size; |
| 383 | | | |
| 384 | | | |
| 385 | | | t = visual->start_time; |
| 386 | | | t += ((double)pletohl(&vpkt_hdr.ts_delta))*1000;
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) |
| |
|
| 387 | | | secs = (time_t)(t/1000000); |
| 388 | | | usecs = (guint32)(t - secs*1000000); |
| 389 | | | wth->phdr.ts.secs = secs; |
| 390 | | | wth->phdr.ts.nsecs = usecs * 1000; |
| 391 | | | |
| 392 | | | |
| 393 | | | |
| 394 | | | |
| 395 | | | |
| 396 | | | |
| 397 | | | |
| 398 | | | |
| 399 | | | |
| 400 | | | |
| 401 | | | |
| 402 | | | wth->phdr.caplen = packet_size; |
| 403 | | | wth->phdr.len = pletohs(&vpkt_hdr.orig_len);
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)) |
| |
|
| 404 | | | |
| 405 | | | switch (wth->file_encap) |
| 406 | | | { |
| 407 | | | case WTAP_ENCAP_ETHERNET: |
| 408 | | | wth->phdr.len -= 4; |
| 409 | | | break; |
| 410 | | | |
| 411 | | | case WTAP_ENCAP_FRELAY_WITH_PHDR: |
| 412 | | | case WTAP_ENCAP_CHDLC_WITH_PHDR: |
| 413 | | | case WTAP_ENCAP_LAPB: |
| 414 | | | wth->phdr.len -= 2; |
| 415 | | | break; |
| 416 | | | |
| 417 | | | |
| 418 | | | case WTAP_ENCAP_ATM_PDUS: |
| 419 | | | |
| 420 | | | case WTAP_ENCAP_TOKEN_RING: |
| 421 | | | default: |
| 422 | | | break; |
| 423 | | | } |
| 424 | | | |
| 425 | | | |
| 426 | | | if (wth->phdr.len < wth->phdr.caplen) |
| 427 | | | { |
| 428 | | | wth->phdr.len = wth->phdr.caplen; |
| 429 | | | } |
| 430 | | | |
| 431 | | | |
| 432 | | | (wth->file_encap, &vpkt_hdr, &vatm_hdr, &wth->); |
| 433 | | | |
| 434 | | | |
| 435 | | | |
| 436 | | | |
| 437 | | | |
| 438 | | | |
| 439 | | | |
| 440 | | | |
| 441 | | | |
| 442 | | | |
| 443 | | | |
| 444 | | | if (wth->file_encap == WTAP_ENCAP_CHDLC_WITH_PHDR) |
| 445 | | | { |
| 446 | | | |
| 447 | | | if (vpkt_hdr.encap_hint == 14) |
| 448 | | | { |
| 449 | | | wth->phdr.pkt_encap = WTAP_ENCAP_PPP_WITH_PHDR; |
| 450 | | | } |
| 451 | | | else |
| 452 | | | { |
| 453 | | | |
| 454 | | | |
| 455 | | | guint8 *buf = buffer_start_ptr(wth->frame_buffer);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/buffer.h |
| |
46 | # define buffer_start_ptr(buffer) ((buffer)->data + (buffer)->start) |
| |
|
| 456 | | | if ((0xff == buf[0]) && (0x03 == buf[1])) |
| 457 | | | { |
| 458 | | | |
| 459 | | | wth->phdr.pkt_encap = WTAP_ENCAP_PPP_WITH_PHDR; |
| 460 | | | } |
| 461 | | | } |
| 462 | | | } |
| 463 | | | return TRUE; |
| 464 | | | } |
| |