Text   |  XML   |  ReML   |   Visible Warnings:

Format String  at file.c:3171

No properties have been set. | edit properties
Jump to warning location ↓ warning details...
Show Events | Options

find_packet

(/home/sate/Testcases/c/cve/wireshark-1.2.0/file.c)expand/collapse
Show more  
 3028  find_packet(capture_file *cf,
 3029              gboolean (*match_function)(capture_file *, frame_data *, void *),
 3030              void *criterion)
 3031  {
 3032    frame_data *start_fd;
 3033    frame_data *fdata;
 3034    frame_data *new_fd = NULL;
 3035    progdlg_t  *progbar = NULL;
 3036    gboolean    stop_flag;
 3037    int         count;
 3038    int         err;
 3039    gchar      *err_info;
 3040    int         row;
 3041    float       progbar_val;
 3042    GTimeVal    start_time;
 3043    gchar       status_str[100];
 3044    int         progbar_nextstep;
 3045    int         progbar_quantum;
 3046    char       *title;
 3047   
 3048    start_fd = cf->current_frame;
 3049    if (start_fd != NULL)  {
 3050      /* Iterate through the list of packets, starting at the packet we've
 3051         picked, calling a routine to run the filter on the packet, see if
 3052         it matches, and stop if so.  */
 3053      count = 0;
 3054      fdata = start_fd;
 3055   
 3056      /* Update the progress bar when it gets to this value. */
 3057      progbar_nextstep = 0;
 3058      /* When we reach the value that triggers a progress bar update,
 3059         bump that value by this amount. */
 3060      progbar_quantum = cf->count/N_PROGBAR_UPDATES;
 3061      /* Progress so far. */
 3062      progbar_val = 0.0f;
 3063   
 3064      stop_flag = FALSE;
 3065      g_get_current_time(&start_time);
 3066   
 3067      fdata = start_fd;
 3068      title = cf->sfilter?cf->sfilter:"";
 3069      for (;;) {
 3070        /* Create the progress bar if necessary.
 3071           We check on every iteration of the loop, so that it takes no 
 3072           longer than the standard time to create it (otherwise, for a
 3073           large file, we might take considerably longer than that standard
 3074           time in order to get to the next progress bar step). */
 3075        if (progbar == NULL)
 3076           progbar = delayed_create_progress_dlg("Searching", title,
 3077             FALSE, &stop_flag, &start_time, progbar_val);
 3078   
 3079        /* Update the progress bar, but do it only N_PROGBAR_UPDATES times;
 3080           when we update it, we have to run the GTK+ main loop to get it 
 3081           to repaint what's pending, and doing so may involve an "ioctl()"
 3082           to see if there's any pending input from an X server, and doing
 3083           that for every packet can be costly, especially on a big file. */
 3084        if (count >= progbar_nextstep) {
 3085          /* let's not divide by zero. I should never be started 
 3086           * with count == 0, so let's assert that
 3087           */
 3088          g_assert(cf->count > 0);
 3089   
 3090          progbar_val = (gfloat) count / cf->count;
 3091   
 3092          if (progbar != NULL) {
 3093            g_snprintf(status_str, sizeof(status_str),
 3094                       "%4u of %u packets", count, cf->count);
 3095            update_progress_dlg(progbar, progbar_val, status_str);
 3096          }
 3097   
 3098          progbar_nextstep += progbar_quantum;
 3099        }
 3100   
 3101        if (stop_flag) {
 3102          /* Well, the user decided to abort the search.  Go back to the 
 3103             frame where we started. */
 3104          new_fd = start_fd;
 3105          break;
 3106        }
 3107   
 3108        /* Go past the current frame. */
 3109        if (cf->sbackward) {
 3110          /* Go on to the previous frame. */
 3111          fdata = fdata->prev;
 3112          if (fdata == NULL) {
 3113            /*
 3114             * XXX - other apps have a bit more of a detailed message
 3115             * for this, and instead of offering "OK" and "Cancel",
 3116             * they offer things such as "Continue" and "Cancel";
 3117             * we need an API for popping up alert boxes with
 3118             * {Verb} and "Cancel".
 3119             */
 3120   
 3121            if (prefs.gui_find_wrap)
 3122            {
 3123                simple_dialog(ESD_TYPE_INFO, ESD_BTN_OK,
 3124                              "%sBeginning of capture exceeded!%s\n\n"
 3125                              "Search is continued from the end of the capture.",
 3126                              simple_dialog_primary_start(), simple_dialog_primary_end());
 3127                fdata = cf->plist_end;    /* wrap around */
 3128            }
 3129            else 
 3130            {
 3131                simple_dialog(ESD_TYPE_INFO, ESD_BTN_OK,
 3132                              "%sBeginning of capture exceeded!%s\n\n"
 3133                              "Try searching forwards.",
 3134                              simple_dialog_primary_start(), simple_dialog_primary_end());
 3135                fdata = start_fd;        /* stay on previous packet */
 3136            }
 3137          }
 3138        } else {
 3139          /* Go on to the next frame. */
 3140          fdata = fdata->next;
 3141          if (fdata == NULL) {
 3142            if (prefs.gui_find_wrap)
 3143            {
 3144                simple_dialog(ESD_TYPE_INFO, ESD_BTN_OK,
 3145                              "%sEnd of capture exceeded!%s\n\n"
 3146                              "Search is continued from the start of the capture.",
 3147                              simple_dialog_primary_start(), simple_dialog_primary_end());
 3148                fdata = cf->plist;        /* wrap around */
 3149            }
 3150            else 
 3151            {
 3152                simple_dialog(ESD_TYPE_INFO, ESD_BTN_OK,
 3153                              "%sEnd of capture exceeded!%s\n\n"
 3154                              "Try searching backwards.",
 3155                              simple_dialog_primary_start(), simple_dialog_primary_end());
 3156                fdata = start_fd;     /* stay on previous packet */
 3157            }
 3158          }
 3159        }
 3160   
 3161        count++;
 3162   
 3163        /* Is this packet in the display? */
 3164        if (fdata->flags.passed_dfilter) {
 3165          /* Yes.  Load its data. */
 3166          if (!wtap_seek_read(cf->wth, fdata->file_off, &cf->pseudo_header,
 3167                          cf->pd, fdata->cap_len, &err, &err_info)) {
 3168            /* Read error.  Report the error, and go back to the frame
 3169               where we started. */
 3170            simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
 3171                          cf_read_error_message(err, err_info), cf->filename);
 3172            new_fd = start_fd;
 3173            break;
 3174          }
 3175   
 3176          /* Does it match the search criterion? */
 3177          if ((*match_function)(cf, fdata, criterion)) {
 3178            new_fd = fdata;
 3179            break;        /* found it! */
 3180          }
 3181        }
 3182   
 3183        if (fdata == start_fd) {
 3184          /* We're back to the frame we were on originally, and that frame 
 3185             doesn't match the search filter.  The search failed. */
 3186          break;
 3187        }
 3188      }
 3189   
 3190      /* We're done scanning the packets; destroy the progress bar if it
 3191         was created. */
 3192      if (progbar != NULL)
 3193        destroy_progress_dlg(progbar);
 3194    }
 3195   
 3196    if (new_fd != NULL) {
 3197      /* We found a frame.  Find what row it's in. */
 3198      row = packet_list_find_row_from_data(new_fd);
 3199      if (row == -1) {
 3200          /* We didn't find a row even though we know that a frame
 3201           * exists that satifies the search criteria. This means that the
 3202           * frame isn't being displayed currently so we can't select it. */
 3203          simple_dialog(ESD_TYPE_INFO, ESD_BTN_OK,
 3204                        "%sEnd of capture exceeded!%s\n\n"
 3205                        "The capture file is probably not fully loaded.",
 3206                        simple_dialog_primary_start(), simple_dialog_primary_end());
 3207          return FALSE;
 3208      }
 3209   
 3210      /* Select that row, make it the focus row, and make it visible. */
 3211      packet_list_set_selected_row(row);
 3212      return TRUE;        /* success */
 3213    } else 
 3214      return FALSE;       /* failure */
 3215  }
Show more  




Change Warning 5600.35910 : Format String

Priority:
State:
Finding:
Owner:
Note: