(/home/sate/Testcases/c/cve/wireshark-1.2.0/file.c) |
| |
| 400 | | | cf_read(capture_file *cf) |
| 401 | | | { |
| 402 | | | int err; |
| 403 | | | gchar *err_info; |
| 404 | | | const gchar *name_ptr; |
| 405 | | | const char *errmsg; |
| 406 | | | char errmsg_errno[1024+1]; |
| 407 | | | gint64 data_offset; |
| 408 | | | progdlg_t *volatile progbar = NULL; |
| 409 | | | gboolean stop_flag; |
| 410 | | | volatile gint64 size; |
| 411 | | | gint64 file_pos; |
| 412 | | | volatile float progbar_val; |
| 413 | | | GTimeVal start_time; |
| 414 | | | gchar status_str[100]; |
| 415 | | | volatile gint64 progbar_nextstep; |
| 416 | | | volatile gint64 progbar_quantum; |
| 417 | | | dfilter_t *dfcode; |
| 418 | | | #ifdef HAVE_LIBPCAP |
| 419 | | | volatile int displayed_once = 0; |
| 420 | | | #endif |
| 421 | | | |
| 422 | | | |
| 423 | | | |
| 424 | | | |
| 425 | | | |
| 426 | | | dfcode=NULL; |
| 427 | | | if(cf->dfilter){ |
| 428 | | | dfilter_compile(cf->dfilter, &dfcode); |
| 429 | | | } |
| 430 | | | |
| 431 | | | cum_bytes=0; |
| 432 | | | |
| 433 | | | reset_tap_listeners(); |
| 434 | | | |
| 435 | | | cf_callback_invoke(cf_cb_file_read_start, cf); |
| 436 | | | |
| 437 | | | name_ptr = get_basename(cf->filename); |
| 438 | | | |
| 439 | | | |
| 440 | | | size = wtap_file_size(cf->wth, NULL); |
| 441 | | | |
| 442 | | | |
| 443 | | | progbar_nextstep = 0; |
| 444 | | | |
| 445 | | | |
| 446 | | | if (size >= 0) |
| 447 | | | progbar_quantum = size/N_PROGBAR_UPDATES; |
| 448 | | | else |
| 449 | | | progbar_quantum = 0; |
| 450 | | | |
| 451 | | | progbar_val = 0.0f; |
| 452 | | | |
| 453 | | | packet_list_freeze(); |
| 454 | | | |
| 455 | | | stop_flag = FALSE; |
| 456 | | | g_get_current_time(&start_time); |
| 457 | | | |
| 458 | | | while ((wtap_read(cf->wth, &err, &err_info, &data_offset))) { |
| 459 | | | if (size >= 0) { |
| 460 | | | |
| 461 | | | |
| 462 | | | |
| 463 | | | |
| 464 | | | |
| 465 | | | if (progbar == NULL) { |
| 466 | | | progbar = delayed_create_progress_dlg("Loading", name_ptr, |
| 467 | | | TRUE, &stop_flag, &start_time, progbar_val); |
| 468 | | | } |
| 469 | | | |
| 470 | | | |
| 471 | | | |
| 472 | | | |
| 473 | | | |
| 474 | | | |
| 475 | | | if (data_offset >= progbar_nextstep) { |
| 476 | | | file_pos = wtap_read_so_far(cf->wth, NULL); |
| 477 | | | progbar_val = (gfloat) file_pos / (gfloat) size; |
| 478 | | | if (progbar_val > 1.0) { |
| 479 | | | |
| 480 | | | |
| 481 | | | size = wtap_file_size(cf->wth, NULL); |
| 482 | | | if (size >= 0) |
| 483 | | | progbar_val = (gfloat) file_pos / (gfloat) size; |
| 484 | | | |
| 485 | | | |
| 486 | | | |
| 487 | | | |
| 488 | | | if (progbar_val > 1.0f) |
| 489 | | | progbar_val = 1.0f; |
| 490 | | | } |
| 491 | | | if (progbar != NULL) { |
| 492 | | | |
| 493 | | | |
| 494 | | | #ifdef HAVE_LIBPCAP |
| 495 | | | if (progbar_quantum > 500000 || displayed_once == 0) { |
| 496 | | | if ((auto_scroll_live || displayed_once == 0 || cf->displayed_count < 1000) && cf->plist_end != NULL) { |
| 497 | | | displayed_once = 1; |
| 498 | | | packet_list_thaw(); |
| 499 | | | if (auto_scroll_live) |
| 500 | | | packet_list_moveto_end(); |
| 501 | | | packet_list_freeze(); |
| 502 | | | } |
| 503 | | | } |
| 504 | | | #endif |
| 505 | | | |
| 506 | | | g_snprintf(status_str, sizeof(status_str), |
| 507 | | | "%" G_GINT64_MODIFIER "dKB of %" G_GINT64_MODIFIER "dKB", |
| 508 | | | file_pos / 1024, size / 1024); |
| 509 | | | update_progress_dlg(progbar, progbar_val, status_str); |
| 510 | | | } |
| 511 | | | progbar_nextstep += progbar_quantum; |
| 512 | | | } |
| 513 | | | } |
| 514 | | | |
| 515 | | | if (stop_flag) { |
| 516 | | | |
| 517 | | | |
| 518 | | | |
| 519 | | | |
| 520 | | | |
| 521 | | | |
| 522 | | | break; |
| 523 | | | } |
| 524 | | | TRY {
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/exceptions.h |
| |
176 | #define TRY \ |
177 | {\ |
178 | except_t *exc; \ |
179 | volatile int except_state = 0; \ |
180 | static const except_id_t catch_spec[] = { \ |
181 | { XCEPT_GROUP_WIRESHARK, XCEPT_CODE_ANY } }; \ |
182 | except_try_push(catch_spec, 1, &exc); \ |
183 | \ |
184 | if(except_state & EXCEPT_CAUGHT) \ |
185 | except_state |= EXCEPT_RETHROWN; \ |
186 | except_state &= ~EXCEPT_CAUGHT; \ |
187 | \ |
188 | if (except_state == 0 && exc == 0) \ |
189 | /* user's code goes here */ |
| |
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/except.h |
| |
143 | #define except_try_push(ID, NUM, PPE) \ |
144 | { \ |
145 | struct except_stacknode except_sn; \ |
146 | struct except_catch except_ch; \ |
147 | except_setup_try(&except_sn, &except_ch, ID, NUM); \ |
148 | if (setjmp(except_ch.except_jmp)) \ |
149 | *(PPE) = &except_ch.except_obj; \ |
150 | else \ |
151 | *(PPE) = 0 |
| |
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/exceptions.h |
| |
165 | #define EXCEPT_CAUGHT 1 /* exception has been caught, no need to rethrow at |
| |
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/exceptions.h |
| |
168 | #define EXCEPT_RETHROWN 2 /* the exception was rethrown from a CATCH |
| |
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/exceptions.h |
| |
165 | #define EXCEPT_CAUGHT 1 /* exception has been caught, no need to rethrow at |
| |
|
| 525 | | | read_packet(cf, dfcode, data_offset); |
| 526 | | | } |
| 527 | | | CATCH(OutOfMemoryError) {
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/exceptions.h |
| |
202 | #define CATCH(x) \ |
203 | if (except_state == 0 && exc != 0 && exc->except_id.except_code == (x) && \ |
204 | (except_state |= EXCEPT_CAUGHT)) \ |
205 | /* user's code goes here */ |
| |
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/exceptions.h |
| |
165 | #define EXCEPT_CAUGHT 1 /* exception has been caught, no need to rethrow at |
| |
|
| 528 | | | gpointer dialog; |
| 529 | | | |
| 530 | | | dialog = simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, |
| 531 | | | "%sOut Of Memory!%s\n" |
| 532 | | | "\n" |
| 533 | | | "Sorry, but Wireshark has to terminate now!\n" |
| 534 | | | "\n" |
| 535 | | | "Some infos / workarounds can be found at:\n" |
| 536 | | | "http://wiki.wireshark.org/KnownBugs/OutOfMemory", |
| 537 | | | simple_dialog_primary_start(), simple_dialog_primary_end()); |
| 538 | | | |
| 539 | | | simple_dialog_set_cb(dialog, outofmemory_cb, NULL); |
| 540 | | | while(1) { |
| 541 | | | main_window_update(); |
| 542 | | | |
| 543 | | | |
| 544 | | | }; |
| 545 | | | break; |
Unreachable Control Flow
The highlighted code will not execute under any circumstances. This may be because of: |
|
| 546 | | | } |
| 547 | | | ENDTRY;
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/exceptions.h |
| |
191 | #define ENDTRY \ |
192 | /* rethrow the exception if necessary */ \ |
193 | if(!(except_state&EXCEPT_CAUGHT) && exc != 0) \ |
194 | except_rethrow(exc); \ |
195 | except_try_pop();\ |
196 | } |
| |
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/exceptions.h |
| |
165 | #define EXCEPT_CAUGHT 1 /* exception has been caught, no need to rethrow at |
| |
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/except.h |
| |
153 | #define except_try_pop() \ |
154 | except_free(except_ch.except_obj.except_dyndata); \ |
155 | except_pop(); \ |
156 | } |
| |
|
| 548 | | | } |
| 549 | | | |
| 550 | | | |
| 551 | | | if (dfcode != NULL){ |
| 552 | | | dfilter_free(dfcode); |
| 553 | | | } |
| 554 | | | |
| 555 | | | |
| 556 | | | if (progbar != NULL) |
| 557 | | | destroy_progress_dlg(progbar); |
| 558 | | | |
| 559 | | | |
| 560 | | | cf->state = FILE_READ_DONE; |
| 561 | | | |
| 562 | | | |
| 563 | | | wtap_sequential_close(cf->wth); |
| 564 | | | |
| 565 | | | |
| 566 | | | |
| 567 | | | postseq_cleanup_all_protocols(); |
| 568 | | | |
| 569 | | | |
| 570 | | | |
| 571 | | | |
| 572 | | | |
| 573 | | | cf->lnk_t = wtap_file_encap(cf->wth); |
| 574 | | | |
| 575 | | | cf->current_frame = cf->first_displayed; |
| 576 | | | cf->current_row = 0; |
| 577 | | | |
| 578 | | | packet_list_thaw(); |
| 579 | | | |
| 580 | | | cf_callback_invoke(cf_cb_file_read_finished, cf); |
| 581 | | | |
| 582 | | | |
| 583 | | | |
| 584 | | | if (cf->first_displayed != NULL) |
| 585 | | | packet_list_select_row(0); |
| 586 | | | |
| 587 | | | if(stop_flag) { |
| 588 | | | simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK, |
| 589 | | | "%sFile loading was cancelled!%s\n" |
| 590 | | | "\n" |
| 591 | | | "The remaining packets in the file were discarded.\n" |
| 592 | | | "\n" |
| 593 | | | "As a lot of packets from the original file will be missing,\n" |
| 594 | | | "remember to be careful when saving the current content to a file.\n", |
| 595 | | | simple_dialog_primary_start(), simple_dialog_primary_end()); |
| 596 | | | return CF_READ_ERROR; |
| 597 | | | } |
| 598 | | | |
| 599 | | | if (err != 0) { |
| 600 | | | |
| 601 | | | |
| 602 | | | |
| 603 | | | switch (err) { |
| 604 | | | |
| 605 | | | case WTAP_ERR_UNSUPPORTED_ENCAP: |
| 606 | | | g_snprintf(errmsg_errno, sizeof(errmsg_errno), |
| 607 | | | "The capture file has a packet with a network type that Wireshark doesn't support.\n(%s)", |
| 608 | | | err_info); |
| 609 | | | g_free(err_info); |
| 610 | | | errmsg = errmsg_errno; |
| 611 | | | break; |
| 612 | | | |
| 613 | | | case WTAP_ERR_CANT_READ: |
| 614 | | | errmsg = "An attempt to read from the capture file failed for" |
| 615 | | | " some unknown reason."; |
| 616 | | | break; |
| 617 | | | |
| 618 | | | case WTAP_ERR_SHORT_READ: |
| 619 | | | errmsg = "The capture file appears to have been cut short" |
| 620 | | | " in the middle of a packet."; |
| 621 | | | break; |
| 622 | | | |
| 623 | | | case WTAP_ERR_BAD_RECORD: |
| 624 | | | g_snprintf(errmsg_errno, sizeof(errmsg_errno), |
| 625 | | | "The capture file appears to be damaged or corrupt.\n(%s)", |
| 626 | | | err_info); |
| 627 | | | g_free(err_info); |
| 628 | | | errmsg = errmsg_errno; |
| 629 | | | break; |
| 630 | | | |
| 631 | | | default: |
| 632 | | | g_snprintf(errmsg_errno, sizeof(errmsg_errno), |
| 633 | | | "An error occurred while reading the" |
| 634 | | | " capture file: %s.", wtap_strerror(err)); |
| 635 | | | errmsg = errmsg_errno; |
| 636 | | | break; |
| 637 | | | } |
| 638 | | | simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", errmsg); |
| 639 | | | return CF_READ_ERROR; |
| 640 | | | } else |
| 641 | | | return CF_READ_OK; |
| 642 | | | } |
| |