aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2008-06-16 21:55:37 +0000
committerGerald Combs <gerald@wireshark.org>2008-06-16 21:55:37 +0000
commita40cf08ddacadc996a4afef9270ddd99bce5366b (patch)
tree834a3f2e6a3447d28a3257384335713b4975c8d4 /epan
parent5ee742503389b0dce28a9cb939c9f863178c7225 (diff)
Fix an off-by-one bug reported by David Ceccanti, as suggested by Guy at
http://www.wireshark.org/lists/wireshark-users/200806/msg00077.html. Add a comment about the usage of gsm_sms_char_7bit_unpack(). svn path=/trunk/; revision=25462
Diffstat (limited to 'epan')
-rw-r--r--epan/dissectors/packet-gsm_sms.c6
-rw-r--r--epan/dissectors/packet-gsm_sms.h13
2 files changed, 17 insertions, 2 deletions
diff --git a/epan/dissectors/packet-gsm_sms.c b/epan/dissectors/packet-gsm_sms.c
index e7d62398d9..204b9e56f6 100644
--- a/epan/dissectors/packet-gsm_sms.c
+++ b/epan/dissectors/packet-gsm_sms.c
@@ -215,6 +215,7 @@ static gint ett_udh_ieis[NUM_UDH_IEIS];
oct); \
}
+#define ADDRBUF_MAX_MESSAGE_SIZE 20
static void
dis_field_addr(tvbuff_t *tvb, proto_tree *tree, guint32 *offset_p, const gchar *title)
{
@@ -227,7 +228,7 @@ dis_field_addr(tvbuff_t *tvb, proto_tree *tree, guint32 *offset_p, const gchar *
guint32 numdigocts;
guint32 length;
guint32 i, j;
- char addrbuf[20];
+ char addrbuf[ADDRBUF_MAX_MESSAGE_SIZE+1];
offset = *offset_p;
@@ -1804,6 +1805,7 @@ dis_field_ud_iei(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint8 length)
/* 9.2.3.24 */
#define NUM_FILL_BITS_MASKS 6
+#define SMS_MAX_MESSAGE_SIZE 160
static void
dis_field_ud(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint32 length, gboolean udhi, guint8 udl,
gboolean seven_bit, gboolean eight_bit, gboolean ucs2, gboolean compressed)
@@ -1818,7 +1820,7 @@ dis_field_ud(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint32 length, gb
guint fill_bits;
guint32 out_len;
char *ustr;
- char messagebuf[160];
+ char messagebuf[SMS_MAX_MESSAGE_SIZE+1];
proto_item *ucs2_item;
gchar *utf8_text = NULL;
GIConv cd;
diff --git a/epan/dissectors/packet-gsm_sms.h b/epan/dissectors/packet-gsm_sms.h
index 2a652b52b9..33c6737215 100644
--- a/epan/dissectors/packet-gsm_sms.h
+++ b/epan/dissectors/packet-gsm_sms.h
@@ -24,6 +24,19 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+/* Convert a 7-bit GSM SMS packed string into an unpacked string.
+ *
+ * @param offset Bit offset of the start of the string.
+ * @param in_length Length of the packed string in bytes.
+ * @param out_length Length of the output string in bytes.
+ * @param input The string to unpack
+ * @param output The buffer for the output string. This buffer must
+ * be pre-allocated and be at least out_length characters
+ * long, or out_length + 1 if you're planning on adding a
+ * terminating '\0'.
+ * @return The number of unpacked characters.
+ */
+
extern int gsm_sms_char_7bit_unpack(unsigned int offset, unsigned int in_length, unsigned int out_length,
const guint8 *input, unsigned char *output);
extern void gsm_sms_char_ascii_decode(unsigned char* dest, const unsigned char* src, int len);