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
This commit is contained in:
Gerald Combs 2008-06-16 21:55:37 +00:00
parent 5ee7425033
commit a40cf08dda
2 changed files with 17 additions and 2 deletions

View File

@ -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;

View File

@ -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);