aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2005-07-09 00:35:13 +0000
committerGuy Harris <guy@alum.mit.edu>2005-07-09 00:35:13 +0000
commit68b1ab41d736945ca00939ef883c15b541baa4c6 (patch)
treecfa97e0d649e96a9dc70a3aae2391ae895e9f622 /epan
parent2c30357c483da1238bfd45455272db93a2ec65c9 (diff)
Use "tvb_get_string()" rather than duplicating its functionality by
hand. Use "g_strdup()" rather than duplicating its functionality by hand. Make the magic number an array of "guint8", as "tvb_memeql()" expects a pointer to "guint8". svn path=/trunk/; revision=14881
Diffstat (limited to 'epan')
-rw-r--r--epan/dissectors/packet-icep.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/epan/dissectors/packet-icep.c b/epan/dissectors/packet-icep.c
index b00f7b326b..af9a36d9e8 100644
--- a/epan/dissectors/packet-icep.c
+++ b/epan/dissectors/packet-icep.c
@@ -72,7 +72,7 @@
#endif /* 0/1 */
/* fixed values taken from the standard */
-#define ICEP_MAGIC "IceP"
+static const guint8 icep_magic[] = { 'I', 'c', 'e', 'P' };
#define ICEP_HEADER_SIZE 14
#define ICEP_MIN_REPLY_SIZE 5
#define ICEP_MIN_PARAMS_SIZE 6
@@ -174,7 +174,6 @@ static void dissect_ice_string(proto_tree *tree, int hf_icep,
*/
guint32 Size = 0;
- const char *p;
char *s = NULL;
(*consumed) = 0;
@@ -259,16 +258,11 @@ static void dissect_ice_string(proto_tree *tree, int hf_icep,
if ( Size != 0 ) {
- p = tvb_get_ptr(tvb, offset, Size);
- s = g_malloc(Size + 1);
- strncpy(s, p, Size);
- s[Size] = '\0';
+ s = tvb_get_string(tvb, offset, Size);
if (tree && add_hf)
proto_tree_add_string(tree, hf_icep, tvb, offset, Size, s);
} else {
- s = g_malloc( strlen("(empty)") + 1 );
- sprintf(s, "(empty)");
- s[strlen("(empty)")] = '\0';
+ s = g_strdup("(empty)");
/* display the 0x00 Size byte when click on a empty ice_string */
if (tree && add_hf)
proto_tree_add_string(tree, hf_icep, tvb, offset - 1, 1, s);
@@ -1246,7 +1240,7 @@ static gboolean dissect_icep(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree
/* check for magic string (taken from packet-giop.c) */
- if ( tvb_memeql(tvb, 0, ICEP_MAGIC, 4) == -1 ) {
+ if ( tvb_memeql(tvb, 0, icep_magic, 4) == -1 ) {
/* Not a ICEP packet. */
return FALSE;
}