diff options
author | gerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7> | 2009-03-30 17:53:41 +0000 |
---|---|---|
committer | gerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7> | 2009-03-30 17:53:41 +0000 |
commit | 35bd0c487d6fc9e3e1e4a3d2fc1b9be915b4e2ba (patch) | |
tree | 0e3f16a0add6b20d5e2aa5b96b72813dfaceb3f7 /epan | |
parent | 5a542923ae10b62730ecbc108aaae4e81d499f8c (diff) |
In packet-enttec.c and packet-fw1.c, replace string pointer tracking with a
string buffer. In packet-ftp.c and packet-gift.c, cast some size_t's.
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@27896 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'epan')
-rw-r--r-- | epan/dissectors/packet-enttec.c | 24 | ||||
-rw-r--r-- | epan/dissectors/packet-ftp.c | 4 | ||||
-rw-r--r-- | epan/dissectors/packet-fw1.c | 16 | ||||
-rw-r--r-- | epan/dissectors/packet-gift.c | 4 |
4 files changed, 18 insertions, 30 deletions
diff --git a/epan/dissectors/packet-enttec.c b/epan/dissectors/packet-enttec.c index aeaa6f1eda..018cb5970e 100644 --- a/epan/dissectors/packet-enttec.c +++ b/epan/dissectors/packet-enttec.c @@ -197,14 +197,13 @@ dissect_enttec_dmx_data(tvbuff_t *tvb, guint offset, proto_tree *tree) static guint8 dmx_data[512]; static guint16 dmx_data_offset[513]; /* 1 extra for last offset */ - static char string[255]; + emem_strbuf_t *dmx_epstr; proto_tree *hi,*si; proto_item *item; guint16 length,r,c,row_count; guint8 v,type,count; guint16 ci,ui,i,start_offset,end_offset; - char* ptr; proto_tree_add_item(tree, hf_enttec_dmx_data_universe, tvb, offset, 1, FALSE); @@ -279,29 +278,22 @@ dissect_enttec_dmx_data(tvbuff_t *tvb, guint offset, proto_tree *tree) si = proto_item_add_subtree(hi, ett_enttec); row_count = (ui/global_disp_col_count) + ((ui%global_disp_col_count) == 0 ? 0 : 1); - ptr = string; - /* XX: In theory the g_snprintf statements below could store '\0' bytes off the end of the */ - /* 'string' buffer'. This is so since g_snprint returns the number of characters which */ - /* "would have been written" (whether or not there was room) and since ptr is always */ - /* incremented by this amount. In practice the string buffer is large enough such that the */ - /* string buffer size is not exceeded even with the maximum number of columns which might */ - /* be displayed. */ - /* ToDo: consider recoding slightly ... */ + dmx_epstr = ep_strbuf_new_label(""); for (r=0; r < row_count;r++) { for (c=0;(c < global_disp_col_count) && (((r*global_disp_col_count)+c) < ui);c++) { if ((c % (global_disp_col_count/2)) == 0) { - ptr += g_snprintf(ptr, sizeof string - strlen(string), " "); + ep_strbuf_append(dmx_epstr, " "); } v = dmx_data[(r*global_disp_col_count)+c]; if (global_disp_chan_val_type == 0) { v = (v * 100) / 255; if (v == 100) { - ptr += g_snprintf(ptr, sizeof string - strlen(string), "FL "); + ep_strbuf_append(dmx_epstr, "FL "); } else { - ptr += g_snprintf(ptr, sizeof string - strlen(string), chan_format[global_disp_chan_val_type], v); + ep_strbuf_append_printf(dmx_epstr, chan_format[global_disp_chan_val_type], v); } } else { - ptr += g_snprintf(ptr, sizeof string - strlen(string), chan_format[global_disp_chan_val_type], v); + ep_strbuf_append_printf(dmx_epstr, chan_format[global_disp_chan_val_type], v); } } @@ -311,8 +303,8 @@ dissect_enttec_dmx_data(tvbuff_t *tvb, guint offset, proto_tree *tree) proto_tree_add_none_format(si,hf_enttec_dmx_data_dmx_data, tvb, offset+start_offset, end_offset-start_offset, - string_format[global_disp_chan_nr_type], (r*global_disp_col_count)+1, string); - ptr = string; + string_format[global_disp_chan_nr_type], (r*global_disp_col_count)+1, dmx_epstr->str); + ep_strbuf_truncate(dmx_epstr, 0); } item = proto_tree_add_item(si, hf_enttec_dmx_data_data_filter, tvb, diff --git a/epan/dissectors/packet-ftp.c b/epan/dissectors/packet-ftp.c index b03a826a59..b21a02b927 100644 --- a/epan/dissectors/packet-ftp.c +++ b/epan/dissectors/packet-ftp.c @@ -451,8 +451,8 @@ dissect_ftp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) next_token = line; } } - offset += next_token - line; - linelen -= next_token - line; + offset += (gint) (next_token - line); + linelen -= (int) (next_token - line); line = next_token; if (tree) { diff --git a/epan/dissectors/packet-fw1.c b/epan/dissectors/packet-fw1.c index 132834e932..c74ac146d7 100644 --- a/epan/dissectors/packet-fw1.c +++ b/epan/dissectors/packet-fw1.c @@ -139,15 +139,12 @@ dissect_fw1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) char *interface_name; guint32 iface_len = 10; guint16 etype; - char *header; - char *p_header; + emem_strbuf_t *header; int i; gboolean found; static const char fw1_header[] = "FW1 Monitor"; -#define MAX_HEADER_LEN 1000 - header=ep_alloc(MAX_HEADER_LEN); - g_snprintf(header, MAX_HEADER_LEN, "FW1 Monitor"); + header = ep_strbuf_new_label(fw1_header); /* Make entries in Protocol column and Info column on summary display */ if (check_col(pinfo->cinfo, COL_PROTOCOL)) @@ -187,9 +184,8 @@ dissect_fw1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /* display all interfaces always in the same order */ for (i=0; i<interface_anzahl; i++) { - p_header = header + strlen(header); if ( strcmp(p_interfaces[i], interface_name) == 0 ) { - g_snprintf(p_header, MAX_HEADER_LEN-(p_header-header), " %c%c %s %c%c", + ep_strbuf_append_printf(header, " %c%c %s %c%c", direction == 'i' ? 'i' : (direction == 'O' ? 'O' : ' '), (direction == 'i' || direction == 'O') ? chain : ' ', p_interfaces[i], @@ -197,19 +193,19 @@ dissect_fw1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) (direction == 'I' || direction == 'o') ? chain : ' ' ); } else { - g_snprintf(p_header, MAX_HEADER_LEN-(p_header-header), " %s ", p_interfaces[i]); + ep_strbuf_append_printf(header, " %s ", p_interfaces[i]); } } if (check_col(pinfo->cinfo, COL_IF_DIR)) - col_add_str(pinfo->cinfo, COL_IF_DIR, header + sizeof(fw1_header) + 1); + col_add_str(pinfo->cinfo, COL_IF_DIR, header->str + sizeof(fw1_header) + 1); if (tree) { if (!fw1_summary_in_tree) /* Do not show the summary in Protocol Tree */ ti = proto_tree_add_protocol_format(tree, proto_fw1, tvb, 0, ETH_HEADER_SIZE, "%s", fw1_header); else - ti = proto_tree_add_protocol_format(tree, proto_fw1, tvb, 0, ETH_HEADER_SIZE, "%s", header); + ti = proto_tree_add_protocol_format(tree, proto_fw1, tvb, 0, ETH_HEADER_SIZE, "%s", header->str); /* create display subtree for the protocol */ fh_tree = proto_item_add_subtree(ti, ett_fw1); diff --git a/epan/dissectors/packet-gift.c b/epan/dissectors/packet-gift.c index c27e450691..e8dcfb1f1e 100644 --- a/epan/dissectors/packet-gift.c +++ b/epan/dissectors/packet-gift.c @@ -108,8 +108,8 @@ dissect_gift(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) tokenlen, "Response Command: %s", format_text(line, tokenlen)); } - offset += next_token - line; - linelen -= next_token - line; + offset += (gint) (next_token - line); + linelen -= (int) (next_token - line); line = next_token; } |