(/home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/ngsniffer.c) |
| |
| 2617 | | | ng_file_seek_rand(wtap *wth, gint64 offset, int whence, int *err) |
| 2618 | | | { |
| 2619 | | | ngsniffer_t *ngsniffer; |
| 2620 | | | gint64 delta; |
| 2621 | | | GList *new, *next; |
| 2622 | | | blob_info_t *next_blob, *new_blob; |
| 2623 | | | |
| 2624 | | | if (wth->file_type == WTAP_FILE_NGSNIFFER_UNCOMPRESSED) |
| 2625 | | | return file_seek(wth->random_fh, offset, whence, err); |
| 2626 | | | |
| 2627 | | | ngsniffer = wth->capture.ngsniffer; |
| 2628 | | | |
| 2629 | | | switch (whence) { |
| 2630 | | | |
| 2631 | | | case SEEK_SET:
x /usr/include/stdio.h |
| |
141 | #define SEEK_SET 0 /* Seek from beginning of file. */ |
| |
|
| 2632 | | | break; |
| 2633 | | | |
| 2634 | | | case SEEK_CUR:
x /usr/include/stdio.h |
| |
142 | #define SEEK_CUR 1 /* Seek from current position. */ |
| |
|
| 2635 | | | offset += ngsniffer->rand.uncomp_offset; |
| 2636 | | | break; |
| 2637 | | | |
| 2638 | | | case SEEK_END:
x /usr/include/stdio.h |
| |
143 | #define SEEK_END 2 /* Seek from end of file. */ |
| |
|
| 2639 | | | g_assert_not_reached();
x /usr/include/glib-2.0/glib/gtestutils.h |
| |
73 | #define g_assert_not_reached() do { g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, NULL); } while (0) |
| |
x /usr/include/glib-2.0/glib/gmacros.h |
| |
160 | # define G_STRFUNC ((const char*) (__PRETTY_FUNCTION__)) |
| |
|
| 2640 | | | break; |
Unreachable Control Flow
The highlighted code will not execute under any circumstances. This may be because of: |
|
| 2641 | | | } |
| 2642 | | | |
| 2643 | | | delta = offset - ngsniffer->rand.uncomp_offset; |
| 2644 | | | |
| 2645 | | | |
| 2646 | | | |
| 2647 | | | new = NULL; |
| 2648 | | | if (delta > 0) { |
| 2649 | | | |
| 2650 | | | |
| 2651 | | | if ((size_t)(ngsniffer->rand.nextout + delta) >= ngsniffer->rand.nbytes) { |
| 2652 | | | |
| 2653 | | | |
| 2654 | | | |
| 2655 | | | new = g_list_next(ngsniffer->current_blob);
x /usr/include/glib-2.0/glib/glist.h |
| |
113 | #define g_list_next(list) ((list) ? (((GList *)(list))->next) : NULL) |
| |
|
| 2656 | | | while (new) { |
| 2657 | | | next = g_list_next(new);
x /usr/include/glib-2.0/glib/glist.h |
| |
113 | #define g_list_next(list) ((list) ? (((GList *)(list))->next) : NULL) |
| |
|
| 2658 | | | if (next == NULL) { |
| 2659 | | | |
| 2660 | | | break; |
| 2661 | | | } |
| 2662 | | | |
| 2663 | | | next_blob = next->data; |
| 2664 | | | |
| 2665 | | | |
| 2666 | | | if (next_blob->blob_uncomp_offset > offset) |
| 2667 | | | break; |
| 2668 | | | |
| 2669 | | | new = next; |
| 2670 | | | } |
| 2671 | | | } |
| 2672 | | | } else if (delta < 0) { |
| 2673 | | | |
| 2674 | | | |
| 2675 | | | if (ngsniffer->rand.nextout + delta < 0) { |
| 2676 | | | |
| 2677 | | | |
| 2678 | | | |
| 2679 | | | new = g_list_previous(ngsniffer->current_blob);
x /usr/include/glib-2.0/glib/glist.h |
| |
112 | #define g_list_previous(list) ((list) ? (((GList *)(list))->prev) : NULL) |
| |
|
| 2680 | | | while (new) { |
| 2681 | | | |
| 2682 | | | |
| 2683 | | | new_blob = new->data; |
| 2684 | | | if (new_blob->blob_uncomp_offset <= offset) |
| 2685 | | | break; |
| 2686 | | | |
| 2687 | | | |
| 2688 | | | new = g_list_previous(new);
x /usr/include/glib-2.0/glib/glist.h |
| |
112 | #define g_list_previous(list) ((list) ? (((GList *)(list))->prev) : NULL) |
| |
|
| 2689 | | | } |
| 2690 | | | } |
| 2691 | | | } |
| 2692 | | | |
| 2693 | | | if (new != NULL) { |
| 2694 | | | |
| 2695 | | | |
| 2696 | | | new_blob = new->data; |
| 2697 | | | |
| 2698 | | | |
| 2699 | | | |
| 2700 | | | if (file_seek(wth->random_fh, new_blob->blob_comp_offset, SEEK_SET, err) == -1)
x /usr/include/stdio.h |
| |
141 | #define SEEK_SET 0 /* Seek from beginning of file. */ |
| |
|
| 2701 | | | return -1; |
| 2702 | | | |
| 2703 | | | |
| 2704 | | | ngsniffer->current_blob = new; |
| 2705 | | | |
| 2706 | | | |
| 2707 | | | |
| 2708 | | | ngsniffer->rand.uncomp_offset = new_blob->blob_uncomp_offset; |
| 2709 | | | ngsniffer->rand.comp_offset = new_blob->blob_comp_offset; |
| 2710 | | | |
| 2711 | | | |
| 2712 | | | if (read_blob(wth->random_fh, &ngsniffer->rand, err) < 0) |
| 2713 | | | return -1; |
| 2714 | | | |
| 2715 | | | |
| 2716 | | | |
| 2717 | | | |
| 2718 | | | |
| 2719 | | | delta = offset - ngsniffer->rand.uncomp_offset; |
| 2720 | | | g_assert(delta >= 0 && (unsigned long)delta < ngsniffer->rand.nbytes);
x /usr/include/glib-2.0/glib/gtestutils.h |
| |
74 | #define g_assert(expr) do { if G_LIKELY (expr) ; else \ |
75 | g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ |
76 | #expr); } while (0) |
| |
x /usr/include/glib-2.0/glib/gmacros.h |
| |
277 | #define G_LIKELY(expr) (__builtin_expect (_G_BOOLEAN_EXPR(expr), 1)) |
| |
x /usr/include/glib-2.0/glib/gmacros.h |
| |
268 | #define _G_BOOLEAN_EXPR(expr) \ |
269 | __extension__ ({ \ |
270 | int _g_boolean_var_; \ |
271 | if (expr) \ |
272 | _g_boolean_var_ = 1; \ |
273 | else \ |
274 | _g_boolean_var_ = 0; \ |
275 | _g_boolean_var_; \ |
276 | }) |
| |
x /usr/include/glib-2.0/glib/gmacros.h |
| |
160 | # define G_STRFUNC ((const char*) (__PRETTY_FUNCTION__)) |
| |
|
| 2721 | | | } |
| 2722 | | | |
| 2723 | | | |
| 2724 | | | |
| 2725 | | | |
| 2726 | | | |
| 2727 | | | ngsniffer->rand.nextout += (int) delta; |
| 2728 | | | ngsniffer->rand.uncomp_offset += delta; |
| 2729 | | | |
| 2730 | | | return offset; |
| 2731 | | | } |
| |