[Patch] to fix problem in packet-sdp.c

"Martin Mathieson" <[email protected]>
Newsgroups gmane.network.ethereal.devel
Message-ID <004601c68692$4f98d0c0$845e6d51@home>
Hi,

This patch fixes a problem in the latest version of packet-sdp.c  on the
anonymous svn server (is it up-to-date?):

- while parsing fmtp lines, the dissector looks for the MPEG4
'profile-level-id' parameter.  If there is no '=' present, it was throwing
an exception and the frame marked as malformed (see e.g. the attached
capture)
- I've added a few comments where the code wasn't obvious to me...

Best regards,
Martin

_______________________________________________
Ethereal-dev mailing list
[email protected]
http://www.ethereal.com/mailman/listinfo/ethereal-dev
packet-sdp.c.diff (application/octet-stream, 2.6 KB)
--- packet-sdp.c	Fri Jun  2 21:42:26 2006
+++ epan/dissectors/packet-sdp.c	Fri Jun  2 21:52:58 2006
@@ -1075,7 +1075,7 @@
 };
 
 static void
-decode_sdp_fmtp(proto_tree *tree, tvbuff_t *tvb,gint offset, gint tokenlen, guint8 *mime_type){
+decode_sdp_fmtp(proto_tree *tree, tvbuff_t *tvb, gint offset, gint tokenlen, guint8 *mime_type){
   gint next_offset;
   gint end_offset;
   guint8 *field_name;
@@ -1083,13 +1083,23 @@
   proto_item *item;
 
   end_offset = offset + tokenlen;
+
+  /* Look for an '=' within this value - this may indicate that there is a
+     profile-level-id parameter to find if the MPEG4 media type is in use */
   next_offset = tvb_find_guint8(tvb,offset,-1,'=');
+  if (next_offset == -1)
+  {
+    /* Give up (and avoid exception) if '=' not found */
+    return;
+  }
 
+  /* Find the name of the parameter */
   tokenlen = next_offset - offset;
-
   field_name = tvb_get_ephemeral_string(tvb, offset, tokenlen);
+
   offset = next_offset;
 
+  /* Dissect the MPEG4 profile-level-id parameter if present */
   if (mime_type != NULL && strcmp(mime_type, "MP4V-ES") == 0) {
     if (strcmp(field_name, "profile-level-id") == 0) {
       offset++;
@@ -1219,10 +1229,11 @@
 
     tokenlen = next_offset - offset;
 
+    /* Media format extends to the next space */
     media_format_item = proto_tree_add_item(sdp_media_attribute_tree,
                                             hf_media_format, tvb, offset,
                                             tokenlen, FALSE);
-
+    /* Append encoding name to format if known */
     if (transport_info->encoding_name)
       proto_item_append_text(media_format_item, " [%s]",
                              transport_info->encoding_name);
@@ -1231,9 +1242,11 @@
 
     offset = next_offset + 1;
 
+    /* There may be 2 parameters given */
     next_offset = tvb_find_guint8(tvb,offset,-1,';');
 
     if(next_offset != -1){
+      /* There are 2 - add the first parameter */
       tokenlen = next_offset - offset;
       fmtp_item = proto_tree_add_item(sdp_media_attribute_tree,
                                       hf_media_format_specific_parameter, tvb,
@@ -1247,6 +1260,7 @@
       offset = next_offset + 1;
     }
 
+    /* Now add remaining (or only) parameter */
     tokenlen = tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);
 
     fmtp_item = proto_tree_add_item(sdp_media_attribute_tree,
@@ -1260,6 +1274,7 @@
     return;
   }
 
+  /* No special treatment for values of this attribute type, just add as one item. */
   proto_tree_add_item(sdp_media_attribute_tree, hf_media_attribute_value,
                       tvb, offset, -1, FALSE);
 }
sdp2.pcap (application/octet-stream, 830 B) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.