aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2019-07-24 02:50:41 -0700
committerGuy Harris <guy@alum.mit.edu>2019-07-24 17:21:10 +0000
commitc55780951cfd44420d1a40d5e6d68ee20af98338 (patch)
tree88da16dae8a16906449293975f6d3fae1054702e /epan
parent53fddee43b3cb54e11c027135c0c40e6b3d86795 (diff)
Clean up handling of group lists.
Use a wmem_strbuf_t for the group list, so it expands as necessary, rather than a static string buffer. Pass it to dissect_group() through dissect_rpc_list(). For each group, get the group name from the call to dissect_rpc_string(), and append it to the wmem_strbuf_t. Change-Id: I65b36a9b6d34dd1e88babd005fc60ab46331b382 Reviewed-on: https://code.wireshark.org/review/34069 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'epan')
-rw-r--r--epan/dissectors/packet-mount.c44
1 files changed, 18 insertions, 26 deletions
diff --git a/epan/dissectors/packet-mount.c b/epan/dissectors/packet-mount.c
index 6f9506ed33..2376020f79 100644
--- a/epan/dissectors/packet-mount.c
+++ b/epan/dissectors/packet-mount.c
@@ -15,6 +15,7 @@
#include <epan/exceptions.h>
#include <epan/to_str.h>
+#include <epan/strutil.h>
#include "packet-mount.h"
#include "packet-nfs.h"
@@ -85,10 +86,6 @@ static gint ett_mount_exportlist = -1;
static gint ett_mount_pathconf_mask = -1;
static gint ett_mount_statvfs_flag = -1;
-#define MAX_GROUP_NAME_LIST 128
-static char group_name_list[MAX_GROUP_NAME_LIST];
-static int group_names_len;
-
/* RFC 1813, Page 107 */
static const value_string mount3_mountstat3[] =
{
@@ -237,26 +234,16 @@ dissect_mount_dump_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, vo
/* RFC 1094, Page 26 */
/* RFC 1813, Page 110 */
static int
-dissect_group(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
+dissect_group(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, void* data)
{
- int str_len;
-
- if (group_names_len < MAX_GROUP_NAME_LIST - 5) {
- str_len=tvb_get_nstringz(tvb,offset+4,
- MAX_GROUP_NAME_LIST-5-group_names_len,
- 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 - 1;
- } else {
- group_names_len+=str_len;
- group_name_list[group_names_len++]=' ';
- }
- group_name_list[group_names_len]=0;
- }
+ wmem_strbuf_t *group_name_list = (wmem_strbuf_t *)data;
+ const char *group_name;
offset = dissect_rpc_string(tvb, tree,
- hf_mount_groups_group, offset, NULL);
+ hf_mount_groups_group, offset, &group_name);
+ if (wmem_strbuf_get_len(group_name_list) != 0)
+ wmem_strbuf_append_c(group_name_list, ' ');
+ wmem_strbuf_append(group_name_list, group_name);
return offset;
}
@@ -274,9 +261,9 @@ dissect_exportlist(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tr
proto_item* groups_item = NULL;
proto_item* groups_tree = NULL;
const char* directory;
+ wmem_strbuf_t* group_name_list_strbuf;
+ const char* group_name_list;
- group_name_list[0]=0;
- group_names_len=0;
if (tree) {
exportlist_item = proto_tree_add_item(tree, hf_mount_exportlist, tvb, offset, -1, ENC_NA);
exportlist_tree = proto_item_add_subtree(exportlist_item, ett_mount_exportlist);
@@ -289,9 +276,9 @@ dissect_exportlist(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tr
groups_item = proto_tree_add_item(exportlist_tree, hf_mount_groups, tvb, offset, -1, ENC_NA);
groups_tree = proto_item_add_subtree(groups_item, ett_mount_groups);
-
+ group_name_list_strbuf = wmem_strbuf_new(wmem_packet_scope(), "");
offset = dissect_rpc_list(tvb, pinfo, groups_tree, offset,
- dissect_group, NULL);
+ dissect_group, (void *)group_name_list_strbuf);
if (groups_item) {
/* mark empty lists */
if (offset - groups_offset == 4) {
@@ -302,9 +289,14 @@ dissect_exportlist(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tr
proto_item_set_len(groups_item, offset - groups_offset);
}
+ group_name_list = wmem_strbuf_finalize(group_name_list_strbuf);
+
if (exportlist_item) {
/* now we have a nicer string */
- proto_item_set_text(exportlist_item, "Export List Entry: %s -> %s", directory,group_name_list);
+ proto_item_set_text(exportlist_item,
+ "Export List Entry: %s -> %s",
+ format_text(wmem_packet_scope(), directory, strlen(directory)),
+ format_text(wmem_packet_scope(), group_name_list, strlen(group_name_list)));
/* now we know, that exportlist is shorter */
proto_item_set_len(exportlist_item, offset - old_offset);
}