aboutsummaryrefslogtreecommitdiffstats
path: root/packet-ber.c
diff options
context:
space:
mode:
authorRonnie Sahlberg <ronnie_sahlberg@ozemail.com.au>2004-05-26 11:25:20 +0000
committerRonnie Sahlberg <ronnie_sahlberg@ozemail.com.au>2004-05-26 11:25:20 +0000
commitd5f9c8aa92ab5b464fa64c6eaf48acb9d6cb6ac2 (patch)
tree4b4c24546905dd00468b708ecbe79f0e892ccc5e /packet-ber.c
parentc7bf0b4211b6b41850eb5ac25626f05ad44030de (diff)
in dissect_ber_bitstring32()
It is not neccessary that the encoded bitstring is actually encoded as 4 bytes. Make sure, that if the bistring is encoded in less than 4 bytes that we still do the right thing. svn path=/trunk/; revision=11008
Diffstat (limited to 'packet-ber.c')
-rw-r--r--packet-ber.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/packet-ber.c b/packet-ber.c
index 65dd5e1279..57eb1c3624 100644
--- a/packet-ber.c
+++ b/packet-ber.c
@@ -2,7 +2,7 @@
* Helpers for ASN.1/BER dissection
* Ronnie Sahlberg (C) 2004
*
- * $Id: packet-ber.c,v 1.9 2004/05/11 10:57:14 guy Exp $
+ * $Id: packet-ber.c,v 1.10 2004/05/26 11:25:20 sahlberg Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -925,17 +925,29 @@ int dissect_ber_bitstring32(gboolean implicit_tag, packet_info *pinfo, proto_tre
header_field_info *hfi;
char *sep;
gboolean term;
+ unsigned int i, tvb_len;
offset = dissect_ber_bitstring(implicit_tag, pinfo, parent_tree, tvb, offset, NULL, hf_id, ett_id, &tmp_tvb);
tree = proto_item_get_subtree(ber_last_created_item);
if (bit_fields && tree) {
- val = tvb_get_ntohl(tmp_tvb, 0);
+ /* tmp_tvb points to the actual bitstring (including any pad bits at the end.
+ * note that this bitstring is not neccessarily always encoded as 4 bytes
+ * so we have to read it byte by byte.
+ */
+ val=0;
+ tvb_len=tvb_length(tmp_tvb);
+ for(i=0;i<4;i++){
+ val<<=8;
+ if(i<tvb_len){
+ val|=tvb_get_guint8(tmp_tvb,i);
+ }
+ }
bf = bit_fields;
sep = " (";
term = FALSE;
while (*bf) {
- proto_tree_add_item(tree, **bf, tmp_tvb, 0, 4, FALSE);
+ proto_tree_add_boolean(tree, **bf, tmp_tvb, 0, tvb_len, val);
hfi = proto_registrar_get_nth(**bf);
if (val & hfi->bitmask) {
proto_item_append_text(ber_last_created_item, "%s%s", sep, hfi->name);