aboutsummaryrefslogtreecommitdiffstats
path: root/epan/tvbuff.c
diff options
context:
space:
mode:
authorstig <stig@f5534014-38df-0310-8fa8-9805f1628bb7>2009-06-08 08:28:42 +0000
committerstig <stig@f5534014-38df-0310-8fa8-9805f1628bb7>2009-06-08 08:28:42 +0000
commitcb0d1bbf9cb957a9b74cda49464124fda0a9dc15 (patch)
tree5d1d5a3c9dcf575d74ce0ac69cabf4d2f60bb474 /epan/tvbuff.c
parent6fc1fe4c55966b7425da8c105798dc8df69ab15a (diff)
Fixed check for no_of_bits in tvb_get_bits16(), tvb_get_bits32() and
tvb_get_bits64(). git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@28658 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'epan/tvbuff.c')
-rw-r--r--epan/tvbuff.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/epan/tvbuff.c b/epan/tvbuff.c
index 49d3ddeae2..10faec2f6b 100644
--- a/epan/tvbuff.c
+++ b/epan/tvbuff.c
@@ -1524,6 +1524,7 @@ static const guint16 bit_mask16[] = {
0x03ff,
0x01ff
};
+
/* Get 1 - 8 bits */
guint8
tvb_get_bits8(tvbuff_t *tvb, gint bit_offset, gint no_of_bits)
@@ -1555,13 +1556,10 @@ tvb_get_bits8(tvbuff_t *tvb, gint bit_offset, gint no_of_bits)
}
return (guint8)value;
-
}
-
-
/* Get 9 - 16 bits */
-/* Bit offset mask for number of bits = 9 - 32 */
+/* Bit offset mask for number of bits = 16 - 32 */
static const guint32 bit_mask32[] = {
0xffffffff,
0x7fffffff,
@@ -1572,6 +1570,7 @@ static const guint32 bit_mask32[] = {
0x03ffffff,
0x01ffffff
};
+
guint16
tvb_get_bits16(tvbuff_t *tvb, gint bit_offset, gint no_of_bits,gboolean little_endian)
{
@@ -1580,8 +1579,8 @@ tvb_get_bits16(tvbuff_t *tvb, gint bit_offset, gint no_of_bits,gboolean little_e
guint16 tempval = 0;
guint8 tot_no_bits;
- if ((no_of_bits<8)||(no_of_bits>16)) {
- /* If bits < 8 use tvb_get_bits8 */
+ if ((no_of_bits<=8)||(no_of_bits>16)) {
+ /* If bits <= 8 use tvb_get_bits8 */
DISSECTOR_ASSERT_NOT_REACHED();
}
if(little_endian){
@@ -1612,7 +1611,6 @@ tvb_get_bits16(tvbuff_t *tvb, gint bit_offset, gint no_of_bits,gboolean little_e
}
return value;
-
}
/* Bit offset mask for number of bits = 32 - 64 */
@@ -1635,8 +1633,8 @@ tvb_get_bits32(tvbuff_t *tvb, gint bit_offset, gint no_of_bits, gboolean little_
guint32 tempval = 0;
guint8 tot_no_bits;
- if ((no_of_bits<17)||(no_of_bits>32)) {
- /* If bits < 17 use tvb_get_bits8 or tvb_get_bits_ntohs */
+ if ((no_of_bits<=16)||(no_of_bits>32)) {
+ /* If bits <= 16 use tvb_get_bits8 or tvb_get_bits16 */
DISSECTOR_ASSERT_NOT_REACHED();
}
if(little_endian){
@@ -1667,19 +1665,18 @@ tvb_get_bits32(tvbuff_t *tvb, gint bit_offset, gint no_of_bits, gboolean little_
}
return value;
-
}
+
guint64
tvb_get_bits64(tvbuff_t *tvb, gint bit_offset, gint no_of_bits, gboolean little_endian)
{
-
gint offset;
guint64 value = 0;
guint64 tempval = 0;
guint8 tot_no_bits;
- if ((no_of_bits<32)||(no_of_bits>64)) {
- /* If bits < 17 use tvb_get_bits8 or tvb_get_bits_ntohs */
+ if ((no_of_bits<=32)||(no_of_bits>64)) {
+ /* If bits <= 32 use tvb_get_bits8, tvb_get_bits16 or tvb_get_bits32 */
DISSECTOR_ASSERT_NOT_REACHED();
}
if(little_endian){
@@ -1710,7 +1707,6 @@ tvb_get_bits64(tvbuff_t *tvb, gint bit_offset, gint no_of_bits, gboolean little_
}
return value;
-
}
/* Find first occurence of needle in tvbuff, starting at offset. Searches