BoundsError exception in text MEGACO packets

"Tarlovskij Eugene" <[email protected]>
Newsgroups gmane.network.ethereal.devel
Message-ID <[email protected]>
The second problem with MEGACO I've found is here. It is an exception
raising when MEGACO dissector parses audit packets.

Sample audit packet looks like this:

MEGACO/1 <company2.com>:2944
Transaction=6438{
    Context=*{
        AuditValue=user_6{Audit{Media}}
    }
}

The dissector encounters "Audit" descriptor (dissect_megaco_auditdescriptor
function) and calls dissect_megaco_descriptors() from it.
dissect_megaco_descriptors(), in turn, detects word "Media" and passes
control to dissect_megaco_mediadescriptor().

What happens inside dissect_megaco_mediadescriptor() ? The dissector tries
to find "=" character after the word "Media" which is incorrect in this
case.

I've made "quick-n-dirty" fix avoiding tvb_format_text() call if length
parameter less or equal than zero.

Please tell me am I right or wrong with it. I did not committed it to
repository because I'm not sure it is correct way to solve the problem.


Index: packet-megaco.c
===================================================================
--- packet-megaco.c	(revision 18189)
+++ packet-megaco.c	(working copy)
@@ -1346,8 +1346,9 @@
 
 	tvb_current_offset = tvb_find_guint8(tvb, tvb_previous_offset,
tvb_RBRKT, '=');
 	tokenlen = tvb_current_offset  - tvb_previous_offset -1;
-	proto_tree_add_text(megaco_mediadescriptor_tree, tvb,
tvb_previous_offset, tokenlen,
-		"%s",	tvb_format_text(tvb, tvb_previous_offset,
tokenlen));
+	if (tokenlen > 0)
+		proto_tree_add_text(megaco_mediadescriptor_tree, tvb,
tvb_previous_offset, tokenlen,
+			"%s",	tvb_format_text(tvb, tvb_previous_offset,
tokenlen));
 
 	tvb_next_offset = tvb_find_guint8(tvb, tvb_previous_offset,
tvb_RBRKT, '{');
 	/* If a StreamID is present */




Eugene Tarlovskij
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.