diff --git a/epan/addr_resolv.c b/epan/addr_resolv.c index 5e05d68416..a52981bd57 100644 --- a/epan/addr_resolv.c +++ b/epan/addr_resolv.c @@ -1213,7 +1213,7 @@ get_ethbyname(const gchar *name) set_ethent(g_pethers_path); - while ((eth = get_ethent(NULL, FALSE)) && strncmp(name, eth->name, MAXNAMELEN) != 0) + while (((eth = get_ethent(NULL, FALSE)) != NULL) && strncmp(name, eth->name, MAXNAMELEN) != 0) ; if (eth == NULL) { @@ -1221,7 +1221,7 @@ get_ethbyname(const gchar *name) set_ethent(g_ethers_path); - while ((eth = get_ethent(NULL, FALSE)) && strncmp(name, eth->name, MAXNAMELEN) != 0) + while (((eth = get_ethent(NULL, FALSE)) != NULL) && strncmp(name, eth->name, MAXNAMELEN) != 0) ; end_ethent(); @@ -1239,7 +1239,7 @@ get_ethbyaddr(const guint8 *addr) set_ethent(g_pethers_path); - while ((eth = get_ethent(NULL, FALSE)) && memcmp(addr, eth->addr, 6) != 0) + while (((eth = get_ethent(NULL, FALSE)) != NULL) && memcmp(addr, eth->addr, 6) != 0) ; if (eth == NULL) { @@ -1247,7 +1247,7 @@ get_ethbyaddr(const guint8 *addr) set_ethent(g_ethers_path); - while ((eth = get_ethent(NULL, FALSE)) && memcmp(addr, eth->addr, 6) != 0) + while (((eth = get_ethent(NULL, FALSE)) != NULL) && memcmp(addr, eth->addr, 6) != 0) ; end_ethent(); @@ -1332,7 +1332,7 @@ add_manuf_name(const guint8 *addr, unsigned int mask, gchar *name) hashmanuf_t *mtp; hashwka_t *(*wka_tp)[HASHETHSIZE], *wtp; - if (mask == 48) { + if (mask >= 48) { /* This is a well-known MAC address; just add this to the Ethernet hash table */ add_eth_name(addr, name); @@ -1832,7 +1832,7 @@ get_ipxnetbyname(const gchar *name) set_ipxnetent(g_ipxnets_path); - while ((ipxnet = get_ipxnetent()) && strncmp(name, ipxnet->name, MAXNAMELEN) != 0) + while (((ipxnet = get_ipxnetent()) != NULL) && strncmp(name, ipxnet->name, MAXNAMELEN) != 0) ; if (ipxnet == NULL) { @@ -1840,7 +1840,7 @@ get_ipxnetbyname(const gchar *name) set_ipxnetent(g_pipxnets_path); - while ((ipxnet = get_ipxnetent()) && strncmp(name, ipxnet->name, MAXNAMELEN) != 0) + while (((ipxnet = get_ipxnetent()) != NULL) && strncmp(name, ipxnet->name, MAXNAMELEN) != 0) ; end_ipxnetent(); @@ -1857,14 +1857,14 @@ get_ipxnetbyaddr(guint32 addr) set_ipxnetent(g_ipxnets_path); - while ((ipxnet = get_ipxnetent()) && (addr != ipxnet->addr) ) ; + while (((ipxnet = get_ipxnetent()) != NULL) && (addr != ipxnet->addr) ) ; if (ipxnet == NULL) { end_ipxnetent(); set_ipxnetent(g_pipxnets_path); - while ((ipxnet = get_ipxnetent()) && (addr != ipxnet->addr) ) + while (((ipxnet = get_ipxnetent()) != NULL) && (addr != ipxnet->addr) ) ; end_ipxnetent(); @@ -2466,7 +2466,7 @@ host_name_lookup_process(gpointer data _U_) { async_dns_queue_head = g_list_first(async_dns_queue_head); - while (async_dns_queue_head && async_dns_in_flight <= prefs.name_resolve_concurrency) { + while (async_dns_queue_head != NULL && async_dns_in_flight <= prefs.name_resolve_concurrency) { caqm = (async_dns_queue_msg_t *) async_dns_queue_head->data; async_dns_queue_head = g_list_remove(async_dns_queue_head, (void *) caqm); if (caqm->family == AF_INET) { diff --git a/epan/dissectors/packet-btobex.c b/epan/dissectors/packet-btobex.c index 3ce630d0f9..07ad3c231d 100644 --- a/epan/dissectors/packet-btobex.c +++ b/epan/dissectors/packet-btobex.c @@ -514,7 +514,9 @@ dissect_btobex(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) if( (code < BTOBEX_CODE_VALS_CONTINUE) || (code == BTOBEX_CODE_VALS_ABORT)) { proto_tree_add_item(st, hf_opcode, next_tvb, offset, 1, FALSE); - last_opcode[pinfo->p2p_dir] = code; + if (pinfo->p2p_dir == P2P_DIR_SENT || pinfo->p2p_dir == P2P_DIR_RECV) { + last_opcode[pinfo->p2p_dir] = code; + } } else { proto_tree_add_item(st, hf_response_code, next_tvb, offset, 1, FALSE); diff --git a/epan/dissectors/packet-isakmp.c b/epan/dissectors/packet-isakmp.c index 950f2ff42b..868e9f728e 100644 --- a/epan/dissectors/packet-isakmp.c +++ b/epan/dissectors/packet-isakmp.c @@ -1767,6 +1767,10 @@ decrypt_payload(tvbuff_t *tvb, packet_info *pinfo, const guint8 *buf, guint buf_ if (decr->secret_len < gcry_cipher_get_algo_keylen(gcry_cipher_algo)) return NULL; cbc_block_size = (guint32) gcry_cipher_get_algo_blklen(gcry_cipher_algo); + if (cbc_block_size > MAX_DIGEST_SIZE) { + /* This shouldn't happen but we pass cbc_block_size to memcpy size below. */ + return NULL; + } switch(decr->hash_alg) { case HMAC_MD5: diff --git a/epan/dissectors/packet-iwarp-mpa.c b/epan/dissectors/packet-iwarp-mpa.c index 0afdad6a9a..f76adcff6c 100644 --- a/epan/dissectors/packet-iwarp-mpa.c +++ b/epan/dissectors/packet-iwarp-mpa.c @@ -826,7 +826,7 @@ dissect_iwarp_mpa(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) } /* Markers are used by either the Initiator or the Responder or both. */ - if (state->ini_exp_m_res || state->res_exp_m_ini) { + if ((state->ini_exp_m_res || state->res_exp_m_ini) && endpoint <= MPA_RESPONDER) { /* find the TCP sequence number of the first FPDU */ if (!state->minfo[endpoint].valid) { @@ -844,7 +844,7 @@ dissect_iwarp_mpa(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) return FALSE; /* removes Markers if any and prepares new tvbuff for next dissector */ - if (state->minfo[endpoint].valid + if (endpoint <= MPA_RESPONDER && state->minfo[endpoint].valid && number_of_markers(state, tcpinfo, endpoint) > 0) { next_tvb = tvb_new_subset(remove_markers(tvb, pinfo, get_first_marker_offset(state, tcpinfo, endpoint), diff --git a/epan/dissectors/packet-mount.c b/epan/dissectors/packet-mount.c index 2414d02fc6..a6774427f2 100644 --- a/epan/dissectors/packet-mount.c +++ b/epan/dissectors/packet-mount.c @@ -270,7 +270,7 @@ dissect_group(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tre group_name_list+group_names_len); if((group_names_len>=(MAX_GROUP_NAME_LIST-5))||(str_len<0)){ g_snprintf(group_name_list+(MAX_GROUP_NAME_LIST-5), 5, "..."); - group_names_len=MAX_GROUP_NAME_LIST; + group_names_len=MAX_GROUP_NAME_LIST - 1; } else { group_names_len+=str_len; group_name_list[group_names_len++]=' '; diff --git a/gtk/capture_if_details_dlg_win32.c b/gtk/capture_if_details_dlg_win32.c index fbe996b928..bb43293d82 100644 --- a/gtk/capture_if_details_dlg_win32.c +++ b/gtk/capture_if_details_dlg_win32.c @@ -305,7 +305,7 @@ typedef struct _NDIS_802_11_FIXED_IEs #define NDIS_ESSID_MAX_SIZE 32 struct ndis_essid { ULONG length; - UCHAR essid[NDIS_ESSID_MAX_SIZE]; + UCHAR essid[NDIS_ESSID_MAX_SIZE+1]; }; diff --git a/win32/file_dlg_win32.c b/win32/file_dlg_win32.c index 5f93cfc37b..fa319af24f 100644 --- a/win32/file_dlg_win32.c +++ b/win32/file_dlg_win32.c @@ -122,7 +122,7 @@ static TCHAR *build_file_type_list(gboolean save, int *item_to_select); static int file_type_from_list_index(gboolean save, int index); static int filetype; -static packet_range_t range; +static packet_range_t g_range; static merge_action_e merge_action; static print_args_t print_args; /* XXX - The reason g_sf_hwnd exists is so that we can call @@ -334,7 +334,7 @@ win32_save_as_file(HWND h_wnd, action_after_save_e action_after_save, gpointer a g_free(str); goto AGAIN; } - if (cf_save(&cfile, file_name8->str, &range, filetype, FALSE) != CF_OK) { + if (cf_save(&cfile, file_name8->str, &g_range, filetype, FALSE) != CF_OK) { /* The write failed. Try again. */ AGAIN: g_string_free(file_name8, TRUE /* free_segment */); @@ -392,7 +392,7 @@ win32_merge_file (HWND h_wnd) { OPENFILENAME *ofn; TCHAR file_name[MAX_PATH] = _T(""); char *dirname; - cf_status_t merge_status; + cf_status_t merge_status = CF_ERROR; char *in_filenames[2]; int err; char *tmpname; @@ -1292,7 +1292,7 @@ file_type_from_list_index(gboolean save, int index) { /* Check all file types. */ curr_index = 0; for (ft = 0; ft < WTAP_NUM_FILE_TYPES; ft++) { - if (save && (!packet_range_process_all(&range) || ft != cfile.cd_t)) { + if (save && (!packet_range_process_all(&g_range) || ft != cfile.cd_t)) { /* not all unfiltered packets or a different file type. We have to use Wiretap. */ if (!can_save_with_wiretap(ft)) continue; /* We can't. */ @@ -1346,7 +1346,7 @@ build_file_type_list(gboolean save, int *item_to_select) { /* Check all file types. */ index = 1; /* the index is one based! */ for (ft = 0; ft < WTAP_NUM_FILE_TYPES; ft++) { - if (save && (!packet_range_process_all(&range) || ft != cfile.cd_t)) { + if (save && (!packet_range_process_all(&g_range) || ft != cfile.cd_t)) { /* not all unfiltered packets or a different file type. We have to use Wiretap. */ if (!can_save_with_wiretap(ft)) continue; /* We can't. */ @@ -1400,7 +1400,7 @@ build_file_format_list(HWND sf_hwnd) { /* Check all file types. */ index = 0; for (ft = 0; ft < WTAP_NUM_FILE_TYPES; ft++) { - if (!packet_range_process_all(&range) || ft != cfile.cd_t) { + if (!packet_range_process_all(&g_range) || ft != cfile.cd_t) { /* not all unfiltered packets or a different file type. We have to use Wiretap. */ if (!can_save_with_wiretap(ft)) continue; /* We can't. */ @@ -1445,12 +1445,12 @@ save_as_file_hook_proc(HWND sf_hwnd, UINT msg, WPARAM w_param, LPARAM l_param) { filetype = cfile.cd_t; /* init the packet range */ - packet_range_init(&range); + packet_range_init(&g_range); /* Fill in the file format list */ /*build_file_format_list(sf_hwnd);*/ - range_handle_wm_initdialog(sf_hwnd, &range); + range_handle_wm_initdialog(sf_hwnd, &g_range); break; case WM_COMMAND: @@ -1483,7 +1483,7 @@ save_as_file_hook_proc(HWND sf_hwnd, UINT msg, WPARAM w_param, LPARAM l_param) { break; #endif default: - range_handle_wm_command(sf_hwnd, cur_ctrl, w_param, &range); + range_handle_wm_command(sf_hwnd, cur_ctrl, w_param, &g_range); break; } break; @@ -1528,13 +1528,13 @@ save_as_file_hook_proc(HWND sf_hwnd, UINT msg, WPARAM w_param, LPARAM l_param) { } - +#define STATIC_LABEL_CHARS 100 /* For each range static control, fill in its value and enable/disable it. */ static void range_update_dynamics(HWND dlg_hwnd, packet_range_t *range) { HWND cur_ctrl; gboolean filtered_active = FALSE; - TCHAR static_val[100]; + TCHAR static_val[STATIC_LABEL_CHARS]; gint selected_num; guint32 ignored_cnt = 0, displayed_ignored_cnt = 0; @@ -1546,18 +1546,18 @@ range_update_dynamics(HWND dlg_hwnd, packet_range_t *range) { cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_ALL_PKTS_CAP); EnableWindow(cur_ctrl, !filtered_active); if (range->remove_ignored) { - _snwprintf(static_val, sizeof(static_val), _T("%u"), cfile.count - range->ignored_cnt); + _snwprintf(static_val, STATIC_LABEL_CHARS, _T("%u"), cfile.count - range->ignored_cnt); } else { - _snwprintf(static_val, sizeof(static_val), _T("%u"), cfile.count); + _snwprintf(static_val, STATIC_LABEL_CHARS, _T("%u"), cfile.count); } SetWindowText(cur_ctrl, static_val); cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_ALL_PKTS_DISP); EnableWindow(cur_ctrl, filtered_active); if (range->remove_ignored) { - _snwprintf(static_val, sizeof(static_val), _T("%u"), range->displayed_cnt - range->displayed_ignored_cnt); + _snwprintf(static_val, STATIC_LABEL_CHARS, _T("%u"), range->displayed_cnt - range->displayed_ignored_cnt); } else { - _snwprintf(static_val, sizeof(static_val), _T("%u"), range->displayed_cnt); + _snwprintf(static_val, STATIC_LABEL_CHARS, _T("%u"), range->displayed_cnt); } SetWindowText(cur_ctrl, static_val); @@ -1566,18 +1566,18 @@ range_update_dynamics(HWND dlg_hwnd, packet_range_t *range) { cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_SEL_PKT_CAP); EnableWindow(cur_ctrl, selected_num && !filtered_active); if (range->remove_ignored && cfile.current_frame && cfile.current_frame->flags.ignored) { - _snwprintf(static_val, sizeof(static_val), _T("0")); + _snwprintf(static_val, STATIC_LABEL_CHARS, _T("0")); } else { - _snwprintf(static_val, sizeof(static_val), _T("%u"), selected_num ? 1 : 0); + _snwprintf(static_val, STATIC_LABEL_CHARS, _T("%u"), selected_num ? 1 : 0); } SetWindowText(cur_ctrl, static_val); cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_SEL_PKT_DISP); EnableWindow(cur_ctrl, selected_num && filtered_active); if (range->remove_ignored && cfile.current_frame && cfile.current_frame->flags.ignored) { - _snwprintf(static_val, sizeof(static_val), _T("0")); + _snwprintf(static_val, STATIC_LABEL_CHARS, _T("0")); } else { - _snwprintf(static_val, sizeof(static_val), _T("%u"), selected_num ? 1 : 0); + _snwprintf(static_val, STATIC_LABEL_CHARS, _T("%u"), selected_num ? 1 : 0); } SetWindowText(cur_ctrl, static_val); @@ -1588,18 +1588,18 @@ range_update_dynamics(HWND dlg_hwnd, packet_range_t *range) { cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_MARKED_CAP); EnableWindow(cur_ctrl, cfile.marked_count && !filtered_active); if (range->remove_ignored) { - _snwprintf(static_val, sizeof(static_val), _T("%u"), cfile.marked_count - range->ignored_marked_cnt); + _snwprintf(static_val, STATIC_LABEL_CHARS, _T("%u"), cfile.marked_count - range->ignored_marked_cnt); } else { - _snwprintf(static_val, sizeof(static_val), _T("%u"), cfile.marked_count); + _snwprintf(static_val, STATIC_LABEL_CHARS, _T("%u"), cfile.marked_count); } SetWindowText(cur_ctrl, static_val); cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_MARKED_DISP); EnableWindow(cur_ctrl, cfile.marked_count && filtered_active); if (range->remove_ignored) { - _snwprintf(static_val, sizeof(static_val), _T("%u"), range->displayed_marked_cnt - range->displayed_ignored_marked_cnt); + _snwprintf(static_val, STATIC_LABEL_CHARS, _T("%u"), range->displayed_marked_cnt - range->displayed_ignored_marked_cnt); } else { - _snwprintf(static_val, sizeof(static_val), _T("%u"), range->displayed_marked_cnt); + _snwprintf(static_val, STATIC_LABEL_CHARS, _T("%u"), range->displayed_marked_cnt); } SetWindowText(cur_ctrl, static_val); @@ -1610,18 +1610,18 @@ range_update_dynamics(HWND dlg_hwnd, packet_range_t *range) { cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_FIRST_LAST_CAP); EnableWindow(cur_ctrl, range->mark_range_cnt && !filtered_active); if (range->remove_ignored) { - _snwprintf(static_val, sizeof(static_val), _T("%u"), range->mark_range_cnt - range->ignored_mark_range_cnt); + _snwprintf(static_val, STATIC_LABEL_CHARS, _T("%u"), range->mark_range_cnt - range->ignored_mark_range_cnt); } else { - _snwprintf(static_val, sizeof(static_val), _T("%u"), range->mark_range_cnt); + _snwprintf(static_val, STATIC_LABEL_CHARS, _T("%u"), range->mark_range_cnt); } SetWindowText(cur_ctrl, static_val); cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_FIRST_LAST_DISP); EnableWindow(cur_ctrl, range->displayed_mark_range_cnt && filtered_active); if (range->remove_ignored) { - _snwprintf(static_val, sizeof(static_val), _T("%u"), range->displayed_mark_range_cnt - range->displayed_ignored_mark_range_cnt); + _snwprintf(static_val, STATIC_LABEL_CHARS, _T("%u"), range->displayed_mark_range_cnt - range->displayed_ignored_mark_range_cnt); } else { - _snwprintf(static_val, sizeof(static_val), _T("%u"), range->displayed_mark_range_cnt); + _snwprintf(static_val, STATIC_LABEL_CHARS, _T("%u"), range->displayed_mark_range_cnt); } SetWindowText(cur_ctrl, static_val); @@ -1629,18 +1629,18 @@ range_update_dynamics(HWND dlg_hwnd, packet_range_t *range) { cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_RANGE_CAP); EnableWindow(cur_ctrl, !filtered_active); if (range->remove_ignored) { - _snwprintf(static_val, sizeof(static_val), _T("%u"), range->user_range_cnt - range->ignored_user_range_cnt); + _snwprintf(static_val, STATIC_LABEL_CHARS, _T("%u"), range->user_range_cnt - range->ignored_user_range_cnt); } else { - _snwprintf(static_val, sizeof(static_val), _T("%u"), range->user_range_cnt); + _snwprintf(static_val, STATIC_LABEL_CHARS, _T("%u"), range->user_range_cnt); } SetWindowText(cur_ctrl, static_val); cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_RANGE_DISP); EnableWindow(cur_ctrl, filtered_active); if (range->remove_ignored) { - _snwprintf(static_val, sizeof(static_val), _T("%u"), range->displayed_user_range_cnt - range->displayed_ignored_user_range_cnt); + _snwprintf(static_val, STATIC_LABEL_CHARS, _T("%u"), range->displayed_user_range_cnt - range->displayed_ignored_user_range_cnt); } else { - _snwprintf(static_val, sizeof(static_val), _T("%u"), range->displayed_user_range_cnt); + _snwprintf(static_val, STATIC_LABEL_CHARS, _T("%u"), range->displayed_user_range_cnt); } SetWindowText(cur_ctrl, static_val); @@ -1675,12 +1675,12 @@ range_update_dynamics(HWND dlg_hwnd, packet_range_t *range) { cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_IGNORED_CAP); EnableWindow(cur_ctrl, ignored_cnt && !filtered_active); - _snwprintf(static_val, sizeof(static_val), _T("%u"), ignored_cnt); + _snwprintf(static_val, STATIC_LABEL_CHARS, _T("%u"), ignored_cnt); SetWindowText(cur_ctrl, static_val); cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_IGNORED_DISP); EnableWindow(cur_ctrl, displayed_ignored_cnt && filtered_active); - _snwprintf(static_val, sizeof(static_val), _T("%u"), displayed_ignored_cnt); + _snwprintf(static_val, STATIC_LABEL_CHARS, _T("%u"), displayed_ignored_cnt); SetWindowText(cur_ctrl, static_val); } @@ -1934,13 +1934,13 @@ static UINT_PTR CALLBACK export_raw_file_hook_proc(HWND ef_hwnd, UINT msg, WPARAM w_param, LPARAM l_param) { HWND cur_ctrl; OPENFILENAME *ofnp = (OPENFILENAME *) l_param; - TCHAR raw_msg[100]; + TCHAR raw_msg[STATIC_LABEL_CHARS]; OFNOTIFY *notify = (OFNOTIFY *) l_param; switch(msg) { case WM_INITDIALOG: - _snwprintf(raw_msg, sizeof(raw_msg), _T("%d byte%s of raw binary data will be written"), - ofnp->lCustData, plurality(ofnp->lCustData, "", "s")); + _snwprintf(raw_msg, STATIC_LABEL_CHARS, _T("%d byte%s of raw binary data will be written"), + ofnp->lCustData, utf_8to16(plurality(ofnp->lCustData, "", "s"))); cur_ctrl = GetDlgItem(ef_hwnd, EWFD_EXPORTRAW_ST); SetWindowText(cur_ctrl, raw_msg); break;