aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorPascal Quantin <pascal.quantin@gmail.com>2015-03-10 23:11:59 +0100
committerPascal Quantin <pascal.quantin@gmail.com>2015-03-12 22:00:07 +0000
commit803d1201486d515637a391620a75c5b69e9c9b30 (patch)
treec5faced5c8266d417d1a11447b4fd127a8805194 /epan
parent17b57ecbf8638fb1ed38194ebcfc523ad0473dac (diff)
PER: fix dissection of known-multiplier character strings with ub less or equal to 2^b-1
See ITU-T X.691 chapter 30.5 for details Change-Id: I6ac31494997349c6bff19b196e72859a31634af4 Ping-Bug: 11039 Reviewed-on: https://code.wireshark.org/review/7633 Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Diffstat (limited to 'epan')
-rw-r--r--epan/dissectors/packet-per.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/epan/dissectors/packet-per.c b/epan/dissectors/packet-per.c
index ca14c4a6a0..d1f8a3249d 100644
--- a/epan/dissectors/packet-per.c
+++ b/epan/dissectors/packet-per.c
@@ -569,10 +569,11 @@ DEBUG_ENTRY("dissect_per_sequence_of");
/* XXX we don't do >64k length strings yet */
static guint32
-dissect_per_restricted_character_string_sorted(tvbuff_t *tvb, guint32 offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index, int min_len, int max_len, gboolean has_extension _U_,const char *alphabet, int alphabet_length, tvbuff_t **value_tvb)
+dissect_per_restricted_character_string_sorted(tvbuff_t *tvb, guint32 offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index, int min_len, int max_len,
+ gboolean has_extension _U_, guint16 lb _U_, guint16 ub, const char *alphabet, int alphabet_length, tvbuff_t **value_tvb)
{
guint32 length;
- gboolean byte_aligned;
+ gboolean byte_aligned, use_canonical_order;
guint8 *buf;
guint char_pos;
int bits_per_char;
@@ -678,6 +679,11 @@ DEBUG_ENTRY("dissect_per_restricted_character_string");
BYTE_ALIGN_OFFSET(offset);
}
+ /* 30.5: if "ub" is less than or equal to 2^b-1, then "v" is the value specified in above , else
+ the characters are placed in the canonical order defined in ITU-T Rec. X.680 | ISO/IEC 8824-1,
+ clause 43. The first is assigned the value zero and the next in canonical order is assigned a value
+ that is one greater than the value assigned to the previous character in the canonical order. These are the values "v" */
+ use_canonical_order = (ub <= ((guint16)(1<<bits_per_char)-1)) ? FALSE : TRUE;
buf = (guint8 *)wmem_alloc(actx->pinfo->pool, length+1);
old_offset=offset;
@@ -691,11 +697,7 @@ DEBUG_ENTRY("dissect_per_restricted_character_string");
offset=dissect_per_boolean(tvb, offset, actx, tree, -1, &bit);
val=(val<<1)|bit;
}
- /* ALIGNED PER does not do any remapping of chars if
- bitsperchar is 8
- */
- /* If alphabet is not provided, do not do any remapping either */
- if((bits_per_char==8) || (alphabet==NULL)){
+ if(use_canonical_order == FALSE){
buf[char_pos]=val;
} else {
if (val < alphabet_length){
@@ -750,17 +752,15 @@ dissect_per_restricted_character_string(tvbuff_t *tvb, guint32 offset, asn1_ctx_
} else {
alphabet_ptr = sort_alphabet(sorted_alphabet, alphabet, alphabet_length);
}
- return dissect_per_restricted_character_string_sorted(tvb, offset, actx, tree, hf_index, min_len, max_len, has_extension, alphabet_ptr, alphabet_length, value_tvb);
+ /* Not a known-multiplier character string: enforce lb and ub to max values */
+ return dissect_per_restricted_character_string_sorted(tvb, offset, actx, tree, hf_index, min_len, max_len, has_extension, 0, 65535, alphabet_ptr, alphabet_length, value_tvb);
}
-/* dissect a constrained IA5String that consists of the full ASCII set,
- i.e. no FROM stuff limiting the alphabet
-*/
guint32
dissect_per_IA5String(tvbuff_t *tvb, guint32 offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index, int min_len, int max_len, gboolean has_extension)
{
offset=dissect_per_restricted_character_string_sorted(tvb, offset, actx, tree, hf_index, min_len, max_len, has_extension,
- NULL, 128, NULL);
+ 0, 127, NULL, 128, NULL);
return offset;
}
@@ -769,7 +769,7 @@ guint32
dissect_per_NumericString(tvbuff_t *tvb, guint32 offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index, int min_len, int max_len, gboolean has_extension)
{
offset=dissect_per_restricted_character_string_sorted(tvb, offset, actx, tree, hf_index, min_len, max_len, has_extension,
- " 0123456789", 11, NULL);
+ 32, 57, " 0123456789", 11, NULL);
return offset;
}
@@ -777,14 +777,14 @@ guint32
dissect_per_PrintableString(tvbuff_t *tvb, guint32 offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index, int min_len, int max_len, gboolean has_extension)
{
offset=dissect_per_restricted_character_string_sorted(tvb, offset, actx, tree, hf_index, min_len, max_len, has_extension,
- " '()+,-.*0123456789:=?ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 74, NULL);
+ 32, 122, " '()+,-.*0123456789:=?ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 74, NULL);
return offset;
}
guint32
dissect_per_VisibleString(tvbuff_t *tvb, guint32 offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index, int min_len, int max_len, gboolean has_extension)
{
offset=dissect_per_restricted_character_string_sorted(tvb, offset, actx, tree, hf_index, min_len, max_len, has_extension,
- " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~", 95, NULL);
+ 32, 126, " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~", 95, NULL);
return offset;
}
guint32
@@ -831,7 +831,7 @@ guint32
dissect_per_UTF8String(tvbuff_t *tvb, guint32 offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index, int min_len, int max_len, gboolean has_extension _U_)
{
offset=dissect_per_restricted_character_string_sorted(tvb, offset, actx, tree,
- hf_index, min_len, max_len, has_extension, NULL, 256, NULL);
+ hf_index, min_len, max_len, has_extension, 0, 255, NULL, 256, NULL);
return offset;
}