diff options
author | Guy Harris <guy@alum.mit.edu> | 2003-10-25 06:49:45 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2003-10-25 06:49:45 +0000 |
commit | aed6852d6bc1bae4972d8eaa56ed98d96f7fa27a (patch) | |
tree | 932160772f96f0a59742da72d808e5ad045e5759 /packet-per.c | |
parent | 732120717cb7958e752de7552fb13ecd25cad737 (diff) |
In restricted character strings, deal with character values that are
greater than the alphabet length.
Just use "proto_tree_add_item()" if you have a range of bytes, of known
length, that are to be added as an item - that handles both FT_STRING
and FT_BYTES, including null-terminating the string value.
svn path=/trunk/; revision=8779
Diffstat (limited to 'packet-per.c')
-rw-r--r-- | packet-per.c | 28 |
1 files changed, 7 insertions, 21 deletions
diff --git a/packet-per.c b/packet-per.c index 6371a07f60..8e02701ff8 100644 --- a/packet-per.c +++ b/packet-per.c @@ -7,7 +7,7 @@ proper helper routines * Routines for dissection of ASN.1 Aligned PER * 2003 Ronnie Sahlberg * - * $Id: packet-per.c,v 1.21 2003/10/24 10:46:43 sahlberg Exp $ + * $Id: packet-per.c,v 1.22 2003/10/25 06:49:45 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -368,7 +368,10 @@ DEBUG_ENTRY("dissect_per_restricted_character_string"); offset=dissect_per_boolean(tvb, offset, pinfo, tree, -1, &bit, NULL); val=(val<<1)|bit; } - str[char_pos]=alphabet[val]; + if (val >= alphabet_length) + str[char_pos] = '?'; /* XXX - how to mark this? */ + else + str[char_pos]=alphabet[val]; } str[char_pos]=0; proto_tree_add_string(tree, hf_index, tvb, (old_offset>>3), (offset>>3)-(old_offset>>3), str); @@ -1307,7 +1310,6 @@ dissect_per_octet_string(tvbuff_t *tvb, guint32 offset, packet_info *pinfo, prot { guint32 length; header_field_info *hfi; - char *tmpstr; hfi = (hf_index==-1) ? NULL : proto_registrar_get_nth(hf_index); @@ -1363,15 +1365,7 @@ DEBUG_ENTRY("dissect_per_octet_string"); offset=(offset&0xfffffff8)+8; } if (hfi) { - if(hfi->type==FT_STRING){ - tmpstr=g_malloc(min_len+1); - tvb_memcpy(tvb, tmpstr, offset>>3, min_len); - tmpstr[min_len]=0; - proto_tree_add_string(tree, hf_index, tvb, offset>>3, min_len, tmpstr); - g_free(tmpstr); - } else { - proto_tree_add_bytes(tree, hf_index, tvb, offset>>3, min_len, tvb_get_ptr(tvb, offset>>3, min_len)); - } + proto_tree_add_item(tree, hf_index, tvb, offset>>3, min_len, FALSE); } if (value_offset) { *value_offset = offset>>3; @@ -1402,15 +1396,7 @@ DEBUG_ENTRY("dissect_per_octet_string"); offset=(offset&0xfffffff8)+8; } if (hfi) { - if(hfi->type==FT_STRING){ - tmpstr=g_malloc(length+1); - tvb_memcpy(tvb, tmpstr, offset>>3, length); - tmpstr[length]=0; - proto_tree_add_string(tree, hf_index, tvb, offset>>3, length, tmpstr); - g_free(tmpstr); - } else { - proto_tree_add_bytes(tree, hf_index, tvb, offset>>3, length, tvb_get_ptr(tvb, offset>>3, length)); - } + proto_tree_add_item(tree, hf_index, tvb, offset>>3, length, FALSE); } } if (value_offset) { |