Text   |  XML   |  ReML   |   Visible Warnings:

Format String  at file.c:1662

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

rescan_packets

(/home/sate/Testcases/c/cve/wireshark-1.2.0/file.c)expand/collapse
Show more  
 1498  rescan_packets(capture_file *cf, const char *action, const char *action_item,
 1499                  gboolean refilter, gboolean redissect)
 1500  {
 1501    frame_data *fdata;
 1502    progdlg_t  *progbar = NULL;
 1503    gboolean    stop_flag;
 1504    int         count;
 1505    int         err;
 1506    gchar      *err_info;
 1507    frame_data *selected_frame, *preceding_frame, *following_frame, *prev_frame;
 1508    int         selected_row, prev_row, preceding_row, following_row;
 1509    gboolean    selected_frame_seen;
 1510    int         row;
 1511    float       progbar_val;
 1512    GTimeVal    start_time;
 1513    gchar       status_str[100];
 1514    int         progbar_nextstep;
 1515    int         progbar_quantum;
 1516    dfilter_t   *dfcode;
 1517   
 1518    /* Compile the current display filter.
 1519     * We assume this will not fail since cf->dfilter is only set in
 1520     * cf_filter IFF the filter was valid.
 1521     */
 1522    dfcode=NULL;
 1523    if(cf->dfilter){
 1524      dfilter_compile(cf->dfilter, &dfcode);
 1525    }
 1526   
 1527    cum_bytes=0;
 1528    reset_tap_listeners();
 1529    /* Which frame, if any, is the currently selected frame?
 1530       XXX - should the selected frame or the focus frame be the "current"
 1531       frame, that frame being the one from which "Find Frame" searches 
 1532       start? */
 1533    selected_frame = cf->current_frame;
 1534   
 1535    /* We don't yet know what row that frame will be on, if any, after we
 1536       rebuild the clist, however. */
 1537    selected_row = -1;
 1538   
 1539    if (redissect) {
 1540      /* We need to re-initialize all the state information that protocols
 1541         keep, because some preference that controls a dissector has changed,
 1542         which might cause the state information to be constructed differently 
 1543         by that dissector. */
 1544   
 1545      /* We might receive new packets while redissecting, and we don't
 1546         want to dissect those before their time. */
 1547      cf->redissecting = TRUE;
 1548   
 1549      /* Initialize all data structures used for dissection. */
 1550      init_dissection();
 1551    }
 1552   
 1553    /* Freeze the packet list while we redo it, so we don't get any
 1554       screen updates while it happens. */
 1555    packet_list_freeze();
 1556   
 1557    /* Clear it out. */
 1558    packet_list_clear();
 1559   
 1560    /* We don't yet know which will be the first and last frames displayed. */
 1561    cf->first_displayed = NULL;
 1562    cf->last_displayed = NULL;
 1563   
 1564    /* We currently don't display any packets */
 1565    cf->displayed_count = 0;
 1566   
 1567    /* Iterate through the list of frames.  Call a routine for each frame 
 1568       to check whether it should be displayed and, if so, add it to 
 1569       the display list. */
 1570    nstime_set_unset(&first_ts);
 1571    nstime_set_unset(&prev_dis_ts);
 1572   
 1573    /* Update the progress bar when it gets to this value. */
 1574    progbar_nextstep = 0;
 1575    /* When we reach the value that triggers a progress bar update,
 1576       bump that value by this amount. */
 1577    progbar_quantum = cf->count/N_PROGBAR_UPDATES;
 1578    /* Count of packets at which we've looked. */
 1579    count = 0;
 1580    /* Progress so far. */
 1581    progbar_val = 0.0f;
 1582   
 1583    stop_flag = FALSE;
 1584    g_get_current_time(&start_time);
 1585   
 1586    row = -1;             /* no previous row yet */
 1587    prev_row = -1;
 1588    prev_frame = NULL;
 1589   
 1590    preceding_row = -1;
 1591    preceding_frame = NULL;
 1592    following_row = -1;
 1593    following_frame = NULL;
 1594   
 1595    selected_frame_seen = FALSE;
 1596   
 1597    for (fdata = cf->plist; fdata != NULL; fdata = fdata->next) {
 1598      /* Create the progress bar if necessary.
 1599         We check on every iteration of the loop, so that it takes no 
 1600         longer than the standard time to create it (otherwise, for a
 1601         large file, we might take considerably longer than that standard
 1602         time in order to get to the next progress bar step). */
 1603      if (progbar == NULL)
 1604        progbar = delayed_create_progress_dlg(action, action_item, TRUE,
 1605                                              &stop_flag, &start_time,
 1606                                              progbar_val);
 1607   
 1608      /* Update the progress bar, but do it only N_PROGBAR_UPDATES times;
 1609         when we update it, we have to run the GTK+ main loop to get it 
 1610         to repaint what's pending, and doing so may involve an "ioctl()"
 1611         to see if there's any pending input from an X server, and doing
 1612         that for every packet can be costly, especially on a big file. */
 1613      if (count >= progbar_nextstep) {
 1614        /* let's not divide by zero. I should never be started 
 1615         * with count == 0, so let's assert that
 1616         */
 1617        g_assert(cf->count > 0);
 1618        progbar_val = (gfloat) count / cf->count;
 1619   
 1620        if (progbar != NULL) {
 1621          g_snprintf(status_str, sizeof(status_str),
 1622                    "%4u of %u frames", count, cf->count);
 1623          update_progress_dlg(progbar, progbar_val, status_str);
 1624        }
 1625   
 1626        progbar_nextstep += progbar_quantum;
 1627      }
 1628   
 1629      if (stop_flag) {
 1630        /* Well, the user decided to abort the filtering.  Just stop.
 1631   
 1632           XXX - go back to the previous filter?  Users probably just
 1633           want not to wait for a filtering operation to finish;
 1634           unless we cancel by having no filter, reverting to the 
 1635           previous filter will probably be even more expensive than
 1636           continuing the filtering, as it involves going back to the 
 1637           beginning and filtering, and even with no filter we currently 
 1638           have to re-generate the entire clist, which is also expensive.
 1639   
 1640           I'm not sure what Network Monitor does, but it doesn't appear 
 1641           to give you an unfiltered display if you cancel. */
 1642        break;
 1643      }
 1644   
 1645      count++;
 1646   
 1647      if (redissect) {
 1648        /* Since all state for the frame was destroyed, mark the frame 
 1649         * as not visited, free the GSList referring to the state 
 1650         * data (the per-frame data itself was freed by 
 1651         * "init_dissection()"), and null out the GSList pointer. */
 1652        fdata->flags.visited = 0;
 1653        if (fdata->pfd) {
 1654          g_slist_free(fdata->pfd);
 1655          fdata->pfd = NULL;
 1656        }
 1657      }
 1658   
 1659      if (!wtap_seek_read (cf->wth, fdata->file_off, &cf->pseudo_header,
 1660          cf->pd, fdata->cap_len, &err, &err_info)) {
 1661          simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
 1662                        cf_read_error_message(err, err_info), cf->filename);
 1663          break;
 1664      }
 1665   
 1666      /* If the previous frame is displayed, and we haven't yet seen the 
 1667         selected frame, remember that frame - it's the closest one we've
 1668         yet seen before the selected frame. */
 1669      if (prev_row != -1 && !selected_frame_seen) {
 1670        preceding_row = prev_row;
 1671        preceding_frame = prev_frame;
 1672      }
 1673      row = add_packet_to_packet_list(fdata, cf, dfcode, &cf->pseudo_header, cf->pd,
 1674                                          refilter);
 1675   
 1676      /* If this frame is displayed, and this is the first frame we've
 1677         seen displayed after the selected frame, remember this frame -
 1678         it's the closest one we've yet seen at or after the selected 
 1679         frame. */
 1680      if (row != -1 && selected_frame_seen && following_row == -1) {
 1681        following_row = row;
 1682        following_frame = fdata;
 1683      }
 1684      if (fdata == selected_frame) {
 1685        selected_row = row;
 1686        selected_frame_seen = TRUE;
 1687      }
 1688   
 1689      /* Remember this row/frame - it'll be the previous row/frame
 1690         on the next pass through the loop. */
 1691      prev_row = row;
 1692      prev_frame = fdata;
 1693    }
 1694   
 1695    /* We are done redissecting the packet list. */
 1696    cf->redissecting = FALSE;
 1697   
 1698    /* Re-sort the list using the previously selected order */
 1699    packet_list_set_sort_column();
 1700   
 1701    if (redissect) {
 1702      /* Clear out what remains of the visited flags and per-frame data 
 1703         pointers.
 1704   
 1705         XXX - that may cause various forms of bogosity when dissecting 
 1706         these frames, as they won't have been seen by this sequential
 1707         pass, but the only alternative I see is to keep scanning them 
 1708         even though the user requested that the scan stop, and that
 1709         would leave the user stuck with an Wireshark grinding on 
 1710         until it finishes.  Should we just stick them with that? */
 1711      for (; fdata != NULL; fdata = fdata->next) {
 1712        fdata->flags.visited = 0;
 1713        if (fdata->pfd) {
 1714          g_slist_free(fdata->pfd);
 1715          fdata->pfd = NULL;
 1716        }
 1717      }
 1718    }
 1719   
 1720    /* We're done filtering the packets; destroy the progress bar if it
 1721       was created. */
 1722    if (progbar != NULL)
 1723      destroy_progress_dlg(progbar);
 1724   
 1725    /* Unfreeze the packet list. */
 1726    packet_list_thaw();
 1727   
 1728    if (selected_row == -1) {
 1729      /* The selected frame didn't pass the filter. */
 1730      if (selected_frame == NULL) {
 1731        /* That's because there *was* no selected frame.  Make the first
 1732           displayed frame the current frame. */
 1733        selected_row = 0;
 1734      } else {
 1735        /* Find the nearest displayed frame to the selected frame (whether
 1736           it's before or after that frame) and make that the current frame.
 1737           If the next and previous displayed frames are equidistant from the
 1738           selected frame, choose the next one. */
 1739        g_assert(following_frame == NULL ||
 1740                 following_frame->num >= selected_frame->num);
 1741        g_assert(preceding_frame == NULL ||
 1742                 preceding_frame->num <= selected_frame->num);
 1743        if (following_frame == NULL) {
 1744          /* No frame after the selected frame passed the filter, so we
 1745             have to select the last displayed frame before the selected 
 1746             frame. */
 1747          selected_row = preceding_row;
 1748        } else if (preceding_frame == NULL) {
 1749          /* No frame before the selected frame passed the filter, so we
 1750             have to select the first displayed frame after the selected 
 1751             frame. */
 1752          selected_row = following_row;
 1753        } else {
 1754          /* Frames before and after the selected frame passed the filter, so 
 1755             we'll select the previous frame */
 1756          selected_row = preceding_row;
 1757        }
 1758      }
 1759    }
 1760   
 1761    if (selected_row == -1) {
 1762      /* There are no frames displayed at all. */
 1763      cf_unselect_packet(cf);
 1764    } else {
 1765      /* Either the frame that was selected passed the filter, or we've
 1766         found the nearest displayed frame to that frame.  Select it, make 
 1767         it the focus row, and make it visible. */
 1768      if (selected_row == 0) {
 1769        /* Set to invalid to force update of packet list and packet details */
 1770        cf->current_row = -1;
 1771      }
 1772      packet_list_set_selected_row(selected_row);
 1773    }
 1774   
 1775    /* Cleanup and release all dfilter resources */
 1776    if (dfcode != NULL){
 1777      dfilter_free(dfcode);
 1778    }
 1779  }
Show more  




Change Warning 5599.35913 : Format String

Priority:
State:
Finding:
Owner:
Note: