~jelmer/wireshark/daily-ppa

« back to all changes in this revision

Viewing changes to gtk/file_dlg_win32.c

  • Committer: Bazaar Package Importer
  • Author(s): Balint Reczey
  • Date: 2010-11-20 18:41:41 UTC
  • mfrom: (1.1.28 upstream) (42.1.5 experimental)
  • Revision ID: james.westby@ubuntu.com-20101120184141-19e4sxq2kfsdnc9i
Tags: 1.4.2-1
* New upstream release 1.4.2
  - release notes:
    http://www.wireshark.org/docs/relnotes/wireshark-1.4.2.html
  - security fixes
     - Nephi Johnson of BreakingPoint discovered that the LDSS dissector
       could overflow a buffer. (No assigned CVE number.)
     - The ZigBee ZCL dissector could go into an infinite loop.
       (No assigned CVE number.)
* drop 05_fix-display-filter-update-when-changing-profile.patch
  patch since it has been integrated upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* win32-file-dlg.c
2
2
 * Native Windows file dialog routines
3
3
 *
4
 
 * $Id: file_dlg_win32.c 28075 2009-04-17 15:56:53Z wmeier $
 
4
 * $Id: file_dlg_win32.c 34909 2010-11-16 17:43:11Z gerald $
5
5
 *
6
6
 * Wireshark - Network traffic analyzer
7
7
 * By Gerald Combs <gerald@wireshark.org>
60
60
#include "gtk/file_dlg.h"
61
61
#include "gtk/capture_file_dlg.h"
62
62
#include "gtk/main.h"
63
 
#include "gtk/main_menu.h"
 
63
#include "gtk/menus.h"
64
64
#include "gtk/drag_and_drop.h"
65
65
#include "gtk/capture_dlg.h"
66
66
#include "gtk/file_dlg_win32.h"
139
139
 *       being opened/saved/etc.).
140
140
 */
141
141
static HWND           g_sf_hwnd = NULL;
142
 
char *dfilter_open_str = NULL;
143
 
char *dfilter_merge_str = NULL;
 
142
static char *dfilter_str = NULL;
144
143
 
145
144
gboolean
146
145
win32_open_file (HWND h_wnd) {
226
225
        }
227
226
 
228
227
        /* apply our filter */
229
 
        if (dfilter_compile(dfilter_open_str, &dfp)) {
 
228
        if (dfilter_compile(dfilter_str, &dfp)) {
230
229
            cf_set_rfcode(&cfile, dfp);
231
230
        }
232
231
 
233
 
        switch (cf_read(&cfile)) {
 
232
        switch (cf_read(&cfile, FALSE)) {
234
233
            case CF_READ_OK:
235
234
            case CF_READ_ERROR:
236
235
                dirname = get_dirname(utf_16to8(file_name));
480
479
        }
481
480
 
482
481
        /* apply our filter */
483
 
        if (dfilter_compile(dfilter_merge_str, &dfp)) {
 
482
        if (dfilter_compile(dfilter_str, &dfp)) {
484
483
            cf_set_rfcode(&cfile, dfp);
485
484
        }
486
485
 
487
 
        switch (cf_read(&cfile)) {
 
486
        switch (cf_read(&cfile, FALSE)) {
488
487
            case CF_READ_OK:
489
488
            case CF_READ_ERROR:
490
489
                dirname = get_dirname(utf_16to8(file_name));
947
946
    TCHAR       string_buff[PREVIEW_STR_MAX];
948
947
    gint64      data_offset;
949
948
    guint       packet = 0;
950
 
    guint64     filesize;
 
949
    gint64      filesize;
951
950
    time_t      ti_time;
952
951
    struct tm  *ti_tm;
953
952
    guint       elapsed_time;
993
992
 
994
993
        /* size */
995
994
        filesize = wtap_file_size(wth, &err);
996
 
        _snwprintf(string_buff, PREVIEW_STR_MAX, _T("%") _T(PRIu64) _T(" bytes"), filesize);
 
995
        utf_8to16_snprintf(string_buff, PREVIEW_STR_MAX, "%" G_GINT64_FORMAT " bytes", filesize);
997
996
        cur_ctrl = GetDlgItem(of_hwnd, EWFD_PTX_SIZE);
998
997
        SetWindowText(cur_ctrl, string_buff);
999
998
 
1096
1095
        len++;
1097
1096
        strval = g_malloc(len*sizeof(TCHAR));
1098
1097
        len = GetWindowText(hwnd, strval, len);
1099
 
        ret = utf_16to8(strval);
 
1098
        ret = g_utf16_to_utf8(strval, -1, NULL, NULL, NULL);
1100
1099
        g_free(strval);
1101
1100
        return ret;
1102
1101
    } else {
1103
 
        return "";
 
1102
        return NULL;
1104
1103
    }
1105
1104
}
1106
1105
 
1161
1160
    switch(msg) {
1162
1161
        case WM_INITDIALOG:
1163
1162
            /* Retain the filter text, and fill it in. */
1164
 
            if(dfilter_open_str != NULL) {
 
1163
            if(dfilter_str != NULL) {
1165
1164
                cur_ctrl = GetDlgItem(of_hwnd, EWFD_FILTER_EDIT);
1166
 
                SetWindowText(cur_ctrl, utf_8to16(dfilter_open_str));
 
1165
                SetWindowText(cur_ctrl, utf_8to16(dfilter_str));
1167
1166
            }
1168
1167
 
1169
1168
            /* Fill in our resolution values */
1181
1180
                case CDN_FILEOK:
1182
1181
                    /* Fetch the read filter */
1183
1182
                    cur_ctrl = GetDlgItem(of_hwnd, EWFD_FILTER_EDIT);
1184
 
                    dfilter_open_str = filter_tb_get(cur_ctrl);
 
1183
                    if (dfilter_str)
 
1184
                        g_free(dfilter_str);
 
1185
                    dfilter_str = filter_tb_get(cur_ctrl);
1185
1186
 
1186
1187
                    /* Fetch our resolution values */
1187
1188
                    g_resolv_flags = prefs.name_resolve & RESOLV_CONCURRENT;
1489
1490
    gboolean filtered_active = FALSE;
1490
1491
    TCHAR    static_val[100];
1491
1492
    gint     selected_num;
 
1493
    guint32  ignored_cnt = 0, displayed_ignored_cnt = 0;
1492
1494
 
1493
1495
    cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_DISPLAYED_BTN);
1494
1496
    if (SendMessage(cur_ctrl, BM_GETCHECK, 0, 0) == BST_CHECKED)
1497
1499
    /* RANGE_SELECT_ALL */
1498
1500
    cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_ALL_PKTS_CAP);
1499
1501
    EnableWindow(cur_ctrl, !filtered_active);
1500
 
    _snwprintf(static_val, sizeof(static_val), _T("%u"), cfile.count);
 
1502
    if (range->remove_ignored) {
 
1503
        _snwprintf(static_val, sizeof(static_val), _T("%u"), cfile.count - range->ignored_cnt);
 
1504
    } else {
 
1505
        _snwprintf(static_val, sizeof(static_val), _T("%u"), cfile.count);
 
1506
    }
1501
1507
    SetWindowText(cur_ctrl, static_val);
1502
1508
 
1503
1509
    cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_ALL_PKTS_DISP);
1504
1510
    EnableWindow(cur_ctrl, filtered_active);
1505
 
    _snwprintf(static_val, sizeof(static_val), _T("%u"), range->displayed_cnt);
 
1511
    if (range->remove_ignored) {
 
1512
        _snwprintf(static_val, sizeof(static_val), _T("%u"), range->displayed_cnt - range->displayed_ignored_cnt);
 
1513
    } else {
 
1514
        _snwprintf(static_val, sizeof(static_val), _T("%u"), range->displayed_cnt);
 
1515
    }
1506
1516
    SetWindowText(cur_ctrl, static_val);
1507
1517
 
1508
1518
    /* RANGE_SELECT_CURR */
1509
1519
    selected_num = (cfile.current_frame) ? cfile.current_frame->num : 0;
1510
1520
    cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_SEL_PKT_CAP);
1511
1521
    EnableWindow(cur_ctrl, selected_num && !filtered_active);
1512
 
    _snwprintf(static_val, sizeof(static_val), _T("%u"), selected_num ? 1 : 0);
 
1522
    if (range->remove_ignored && cfile.current_frame && cfile.current_frame->flags.ignored) {
 
1523
        _snwprintf(static_val, sizeof(static_val), _T("0"));
 
1524
    } else {
 
1525
        _snwprintf(static_val, sizeof(static_val), _T("%u"), selected_num ? 1 : 0);
 
1526
    }
1513
1527
    SetWindowText(cur_ctrl, static_val);
1514
1528
 
1515
1529
    cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_SEL_PKT_DISP);
1516
1530
    EnableWindow(cur_ctrl, selected_num && filtered_active);
1517
 
    _snwprintf(static_val, sizeof(static_val), _T("%u"), selected_num ? 1 : 0);
 
1531
    if (range->remove_ignored && cfile.current_frame && cfile.current_frame->flags.ignored) {
 
1532
        _snwprintf(static_val, sizeof(static_val), _T("0"));
 
1533
    } else {
 
1534
        _snwprintf(static_val, sizeof(static_val), _T("%u"), selected_num ? 1 : 0);
 
1535
    }
1518
1536
    SetWindowText(cur_ctrl, static_val);
1519
1537
 
1520
1538
    /* RANGE_SELECT_MARKED */
1523
1541
 
1524
1542
    cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_MARKED_CAP);
1525
1543
    EnableWindow(cur_ctrl, cfile.marked_count && !filtered_active);
1526
 
    _snwprintf(static_val, sizeof(static_val), _T("%u"), cfile.marked_count);
 
1544
    if (range->remove_ignored) {
 
1545
        _snwprintf(static_val, sizeof(static_val), _T("%u"), cfile.marked_count - range->ignored_marked_cnt);
 
1546
    } else {
 
1547
        _snwprintf(static_val, sizeof(static_val), _T("%u"), cfile.marked_count);
 
1548
    }
1527
1549
    SetWindowText(cur_ctrl, static_val);
1528
1550
 
1529
1551
    cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_MARKED_DISP);
1530
1552
    EnableWindow(cur_ctrl, cfile.marked_count && filtered_active);
1531
 
    _snwprintf(static_val, sizeof(static_val), _T("%u"), range->displayed_marked_cnt);
 
1553
    if (range->remove_ignored) {
 
1554
        _snwprintf(static_val, sizeof(static_val), _T("%u"), range->displayed_marked_cnt - range->displayed_ignored_marked_cnt);
 
1555
    } else {
 
1556
        _snwprintf(static_val, sizeof(static_val), _T("%u"), range->displayed_marked_cnt);
 
1557
    }
1532
1558
    SetWindowText(cur_ctrl, static_val);
1533
1559
 
1534
1560
    /* RANGE_SELECT_MARKED_RANGE */
1537
1563
 
1538
1564
    cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_FIRST_LAST_CAP);
1539
1565
    EnableWindow(cur_ctrl, range->mark_range_cnt && !filtered_active);
1540
 
    _snwprintf(static_val, sizeof(static_val), _T("%u"), range->mark_range_cnt);
 
1566
    if (range->remove_ignored) {
 
1567
        _snwprintf(static_val, sizeof(static_val), _T("%u"), range->mark_range_cnt - range->ignored_mark_range_cnt);
 
1568
    } else {
 
1569
        _snwprintf(static_val, sizeof(static_val), _T("%u"), range->mark_range_cnt);
 
1570
    }
1541
1571
    SetWindowText(cur_ctrl, static_val);
1542
1572
 
1543
1573
    cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_FIRST_LAST_DISP);
1544
1574
    EnableWindow(cur_ctrl, range->displayed_mark_range_cnt && filtered_active);
1545
 
    _snwprintf(static_val, sizeof(static_val), _T("%u"), range->displayed_mark_range_cnt);
 
1575
    if (range->remove_ignored) {
 
1576
        _snwprintf(static_val, sizeof(static_val), _T("%u"), range->displayed_mark_range_cnt - range->displayed_ignored_mark_range_cnt);
 
1577
    } else {
 
1578
        _snwprintf(static_val, sizeof(static_val), _T("%u"), range->displayed_mark_range_cnt);
 
1579
    }
1546
1580
    SetWindowText(cur_ctrl, static_val);
1547
1581
 
1548
1582
    /* RANGE_SELECT_USER */
1549
1583
    cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_RANGE_CAP);
1550
1584
    EnableWindow(cur_ctrl, !filtered_active);
1551
 
    _snwprintf(static_val, sizeof(static_val), _T("%u"), range->user_range_cnt);
 
1585
    if (range->remove_ignored) {
 
1586
        _snwprintf(static_val, sizeof(static_val), _T("%u"), range->user_range_cnt - range->ignored_user_range_cnt);
 
1587
    } else {
 
1588
        _snwprintf(static_val, sizeof(static_val), _T("%u"), range->user_range_cnt);
 
1589
    }
1552
1590
    SetWindowText(cur_ctrl, static_val);
1553
1591
 
1554
1592
    cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_RANGE_DISP);
1555
1593
    EnableWindow(cur_ctrl, filtered_active);
1556
 
    _snwprintf(static_val, sizeof(static_val), _T("%u"), range->displayed_user_range_cnt);
 
1594
    if (range->remove_ignored) {
 
1595
        _snwprintf(static_val, sizeof(static_val), _T("%u"), range->displayed_user_range_cnt - range->displayed_ignored_user_range_cnt);
 
1596
    } else {
 
1597
        _snwprintf(static_val, sizeof(static_val), _T("%u"), range->displayed_user_range_cnt);
 
1598
    }
 
1599
    SetWindowText(cur_ctrl, static_val);
 
1600
 
 
1601
    /* RANGE_REMOVE_IGNORED_PACKETS */
 
1602
    switch(range->process) {
 
1603
        case(range_process_all):
 
1604
            ignored_cnt = range->ignored_cnt;
 
1605
            displayed_ignored_cnt = range->displayed_ignored_cnt;
 
1606
            break;
 
1607
        case(range_process_selected):
 
1608
            ignored_cnt = (cfile.current_frame && cfile.current_frame->flags.ignored) ? 1 : 0;
 
1609
            displayed_ignored_cnt = ignored_cnt;
 
1610
            break;
 
1611
        case(range_process_marked):
 
1612
            ignored_cnt = range->ignored_marked_cnt;
 
1613
            displayed_ignored_cnt = range->displayed_ignored_marked_cnt;
 
1614
            break;
 
1615
        case(range_process_marked_range):
 
1616
            ignored_cnt = range->ignored_mark_range_cnt;
 
1617
            displayed_ignored_cnt = range->displayed_ignored_mark_range_cnt;
 
1618
            break;
 
1619
        case(range_process_user_range):
 
1620
            ignored_cnt = range->ignored_user_range_cnt;
 
1621
            displayed_ignored_cnt = range->displayed_ignored_user_range_cnt;
 
1622
            break;
 
1623
        default:
 
1624
            g_assert_not_reached();
 
1625
    }
 
1626
 
 
1627
    cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_REMOVE_IGN_CB);
 
1628
    EnableWindow(cur_ctrl, ignored_cnt);
 
1629
 
 
1630
    cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_IGNORED_CAP);
 
1631
    EnableWindow(cur_ctrl, ignored_cnt && !filtered_active);
 
1632
    _snwprintf(static_val, sizeof(static_val), _T("%u"), ignored_cnt);
 
1633
    SetWindowText(cur_ctrl, static_val);
 
1634
 
 
1635
    cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_IGNORED_DISP);
 
1636
    EnableWindow(cur_ctrl, displayed_ignored_cnt && filtered_active);
 
1637
    _snwprintf(static_val, sizeof(static_val), _T("%u"), displayed_ignored_cnt);
1557
1638
    SetWindowText(cur_ctrl, static_val);
1558
1639
}
1559
1640
 
1650
1731
            packet_range_convert_str(range, utf_16to8(range_text));
1651
1732
            range_update_dynamics(dlg_hwnd, range);
1652
1733
            break;
 
1734
        case (BN_CLICKED << 16) | EWFD_REMOVE_IGN_CB:
 
1735
            if (SendMessage(ctrl, BM_GETCHECK, 0, 0) == BST_CHECKED) {
 
1736
                range->remove_ignored = TRUE;
 
1737
            } else {
 
1738
                range->remove_ignored = FALSE;
 
1739
            }
 
1740
            range_update_dynamics(dlg_hwnd, range);
 
1741
            break;
1653
1742
    }
1654
1743
}
1655
1744
 
1666
1755
    switch(msg) {
1667
1756
        case WM_INITDIALOG:
1668
1757
            /* Retain the filter text, and fill it in. */
1669
 
            if(dfilter_merge_str != NULL) {
 
1758
            if(dfilter_str != NULL) {
1670
1759
                cur_ctrl = GetDlgItem(mf_hwnd, EWFD_FILTER_EDIT);
1671
 
                SetWindowText(cur_ctrl, utf_8to16(dfilter_merge_str));
 
1760
                SetWindowText(cur_ctrl, utf_8to16(dfilter_str));
1672
1761
            }
1673
1762
 
1674
1763
            /* Append by default */
1683
1772
                case CDN_FILEOK:
1684
1773
                    /* Fetch the read filter */
1685
1774
                    cur_ctrl = GetDlgItem(mf_hwnd, EWFD_FILTER_EDIT);
1686
 
                    dfilter_merge_str = filter_tb_get(cur_ctrl);
 
1775
                    if (dfilter_str)
 
1776
                        g_free(dfilter_str);
 
1777
                    dfilter_str = filter_tb_get(cur_ctrl);
1687
1778
 
1688
1779
                    cur_ctrl = GetDlgItem(mf_hwnd, EWFD_MERGE_CHRONO_BTN);
1689
1780
                    if(SendMessage(cur_ctrl, BM_GETCHECK, 0, 0) == BST_CHECKED) {