aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-gsm_a_common.c
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2015-11-27 21:05:32 -0500
committerAnders Broman <a.broman58@gmail.com>2015-11-29 00:02:49 +0000
commitcfc47c15c2b902a50764a21cbcd2ba1d78b1de7a (patch)
tree988ff91986715e3c0d0f317ca25548bce025c369 /epan/dissectors/packet-gsm_a_common.c
parentefe1b7aa14bd0b3ca9b671fa0d9413124b58adfa (diff)
Replace my_dgt_tbcd_unpack with the safer tvb_bcd_dig_to_wmem_packet_str.
Bug: 11797 Change-Id: I07fdf3f7564424eac053f4c17de17f0d96597cca Reviewed-on: https://code.wireshark.org/review/12239 Petri-Dish: Michael Mann <mmann78@netscape.net> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-gsm_a_common.c')
-rw-r--r--epan/dissectors/packet-gsm_a_common.c64
1 files changed, 6 insertions, 58 deletions
diff --git a/epan/dissectors/packet-gsm_a_common.c b/epan/dissectors/packet-gsm_a_common.c
index 30123fb17f..5a0d7e6a0a 100644
--- a/epan/dissectors/packet-gsm_a_common.c
+++ b/epan/dissectors/packet-gsm_a_common.c
@@ -758,9 +758,6 @@ static expert_field ei_gsm_a_no_element_dissector = EI_INIT;
static expert_field ei_gsm_a_format_not_supported = EI_INIT;
static expert_field ei_gsm_a_mobile_identity_type = EI_INIT;
-
-static char a_bigbuf[1024];
-
sccp_assoc_info_t* sccp_assoc;
#define NUM_GSM_COMMON_ELEM (sizeof(gsm_common_elem_strings)/sizeof(value_string))
@@ -1935,51 +1932,6 @@ static dgt_set_t Dgt1_9_bcd = {
/* FUNCTIONS */
/*
- * Unpack BCD input pattern into output ASCII pattern
- *
- * Input Pattern is supplied using the same format as the digits
- *
- * Returns: length of unpacked pattern
- */
-int
-my_dgt_tbcd_unpack(
- char *out, /* ASCII pattern out */
- guchar *in, /* packed pattern in */
- int num_octs, /* Number of octets to unpack */
- dgt_set_t *dgt /* Digit definitions */
- )
-{
- int cnt = 0;
- unsigned char i;
-
- while (num_octs)
- {
- /*
- * unpack first value in byte
- */
- i = *in++;
- *out++ = dgt->out[i & 0x0f];
- cnt++;
-
- /*
- * unpack second value in byte
- */
- i >>= 4;
-
- if (i == 0x0f) /* odd number bytes - hit filler */
- break;
-
- *out++ = dgt->out[i & 0xf]; /* ( '& 0xf' added to keep VS Code Analysis happy ) */
- cnt++;
- num_octs--;
- }
-
- *out = '\0';
-
- return cnt;
-}
-
-/*
* Decode the MCC/MNC from 3 octets in 'octs'
*/
static void
@@ -2183,7 +2135,6 @@ de_mid(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guin
{
guint8 oct;
guint32 curr_offset;
- guint8 *poctets;
guint32 value;
gboolean odd;
const gchar *digit_str;
@@ -2260,25 +2211,22 @@ de_mid(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guin
proto_tree_add_item(tree, hf_gsm_a_odd_even_ind, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_gsm_a_mobile_identity_type, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
-
- /* XXX - dynamically allocate a_bigbuf since the only use is now here */
- a_bigbuf[0] = Dgt1_9_bcd.out[(oct & 0xf0) >> 4];
curr_offset++;
- poctets = (guint8 *)tvb_memdup(wmem_packet_scope(), tvb, curr_offset, len - (curr_offset - offset));
+ if (curr_offset - offset >= len) /* Sanity check */
+ return (curr_offset - offset);
- my_dgt_tbcd_unpack(&a_bigbuf[1], poctets, len - (curr_offset - offset),
- &Dgt1_9_bcd);
+ digit_str = tvb_bcd_dig_to_wmem_packet_str(tvb, curr_offset, len - (curr_offset - offset), NULL, FALSE);
proto_tree_add_string_format(tree,
hf_gsm_a_imei,
tvb, curr_offset, len - (curr_offset - offset),
- a_bigbuf,
+ digit_str,
"BCD Digits: %s",
- a_bigbuf);
+ digit_str);
if (add_string)
- g_snprintf(add_string, string_len, " - IMEI (%s)", a_bigbuf);
+ g_snprintf(add_string, string_len, " - IMEI (%s)", digit_str);
curr_offset += len - (curr_offset - offset);
break;