Ethereal-dev: [Ethereal-dev] Patch for JXTA Dissector

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Michael Duigou <ethereal@xxxxxxxxxx>
Date: Tue, 22 Mar 2005 13:51:15 -0800
Provides better handling of unexpected input from segments handing to jxta dissector by tcp. Noticed when "Analyse sequence numbers" was disabled.

slight cleanup of const strings.

Mike
Index: epan/dissectors/packet-jxta.c
===================================================================
--- epan/dissectors/packet-jxta.c	(revision 13865)
+++ epan/dissectors/packet-jxta.c	(working copy)
@@ -53,8 +53,8 @@
 static int proto_jxta = -1;
 static int proto_message_jxta = -1;
 
-static dissector_table_t media_type_dissector_table;
-static dissector_handle_t tcp_jxta_handle;
+static dissector_table_t media_type_dissector_table = NULL;
+static dissector_handle_t tcp_jxta_handle = NULL;
 
 static int hf_jxta_udp = -1;
 static int hf_jxta_udpsig = -1;
@@ -238,7 +238,7 @@
 
 static int dissect_jxta_welcome(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree);
 static int dissect_jxta_message_framing(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, guint64 * content_length,
-                                        const char **content_type);
+                                        char **content_type);
 static int dissect_jxta_message(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree);
 static int dissect_jxta_message_element(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, int ns_count,
                                         const char **namespaces);
@@ -391,7 +391,7 @@
         proto_tree *jxta_udp_tree = proto_item_add_subtree(jxta_udp_tree_item, ett_jxta_udp);
         tvbuff_t *jxta_message_framing_tvb;
         guint64 content_length = -1;
-        const char *content_type = NULL;
+        char *content_type = NULL;
         tvbuff_t *jxta_message_tvb;
         gboolean dissected = FALSE;
         int processed = 0;
@@ -461,12 +461,14 @@
             processed = dissect_jxta_welcome(tvb, pinfo, tree);
         } else {
             guint64 content_length = -1;
-            const char *content_type = NULL;
+            char *content_type = NULL;
             gboolean dissected;
 
             processed = dissect_jxta_message_framing(tvb, pinfo, tree, &content_length, &content_type);
 
-            if (processed > 0) {
+            g_debug( "Dissect : %d %d %s %lld\n", pinfo->fd->num, processed, content_type, content_length );
+
+            if ((processed > 0) && (NULL != content_type) && (-1 != (gint) content_length)) {
                 int msg_offset = offset + processed;
 
                 available = tvb_reported_length_remaining(tvb, msg_offset);
@@ -478,7 +480,7 @@
                     }
 
                     col_set_writable(pinfo->cinfo, FALSE);
-
+                    
                     dissected = dissector_try_string(media_type_dissector_table, content_type, jxta_message_tvb, pinfo, tree);
 
                     if (!dissected) {
@@ -491,7 +493,7 @@
                     processed = available - (int)content_length;
                 }
 
-                g_free((char *)content_type);
+                g_free(content_type);
             }
         }
 
@@ -566,7 +568,7 @@
 *   @return number of bytes from the tvbuff_t which were processed.
 **/
 static int dissect_jxta_message_framing(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, guint64 * content_length,
-                                        const char **content_type)
+                                        char **content_type)
 {
     int offset = 0;
     int available;