mgcp: don't throw an exception while checking if it is our packet

Change-Id: I224a596926e555fd575995b7e19b7aadbb2d8b49
Reviewed-on: https://code.wireshark.org/review/15630
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Martin Kaiser 2016-05-29 18:08:05 +02:00 committed by Anders Broman
parent 68903e7b93
commit aba533c4f7
1 changed files with 12 additions and 0 deletions

View File

@ -697,6 +697,14 @@ static gboolean is_mgcp_verb(tvbuff_t *tvb, gint offset, gint maxlength, const g
gboolean returnvalue = FALSE;
gchar word[5];
/* This function is used for checking if a packet is actually an
mgcp packet. Make sure that we do not throw an exception
during such a check. If we did throw an exeption, we could
not refuse the packet and give other dissectors the chance to
look at it. */
if (tvb_captured_length_remaining(tvb, offset) < (gint)sizeof(word))
return FALSE;
/* Read the string into 'word' and see if it looks like the start of a verb */
if ((maxlength >= 4) && tvb_get_nstringz0(tvb, offset, sizeof(word), word))
{
@ -749,6 +757,10 @@ static gboolean is_mgcp_rspcode(tvbuff_t *tvb, gint offset, gint maxlength)
gboolean returnvalue = FALSE;
guint8 word[4];
/* see the comment in is_mgcp_verb() */
if (tvb_captured_length_remaining(tvb, offset) < (gint)sizeof(word))
return FALSE;
/* Do 1st 3 characters look like digits? */
if (maxlength >= 3)
{