isn't necessarily going to be zero if the item is big-endian.
The last argument to test_length() is an encoding, not a big-endian vs.
little-endian Boolean; name it appropriately.
This fixes bug 8953.
svn path=/trunk/; revision=50806
-/*
- * NOTE: to support code written when proto_tree_add_item() took a
- * gboolean as its last argument, with FALSE meaning "big-endian"
- * and TRUE meaning "little-endian", we treat any non-zero value of
- * "encoding" as meaning "little-endian".
- */
static guint32
get_uint_value(proto_tree *tree, tvbuff_t *tvb, gint offset, gint length, const guint encoding)
{
static guint32
get_uint_value(proto_tree *tree, tvbuff_t *tvb, gint offset, gint length, const guint encoding)
{
- value = encoding ? tvb_get_letohs(tvb, offset)
- : tvb_get_ntohs(tvb, offset);
+ value = (encoding & ENC_LITTLE_ENDIAN) ? tvb_get_letohs(tvb, offset)
+ : tvb_get_ntohs(tvb, offset);
- value = encoding ? tvb_get_letoh24(tvb, offset)
- : tvb_get_ntoh24(tvb, offset);
+ value = (encoding & ENC_LITTLE_ENDIAN) ? tvb_get_letoh24(tvb, offset)
+ : tvb_get_ntoh24(tvb, offset);
- value = encoding ? tvb_get_letohl(tvb, offset)
- : tvb_get_ntohl(tvb, offset);
+ value = (encoding & ENC_LITTLE_ENDIAN) ? tvb_get_letohl(tvb, offset)
+ : tvb_get_ntohl(tvb, offset);
value = 0;
} else {
length_error = FALSE;
value = 0;
} else {
length_error = FALSE;
- value = encoding ? tvb_get_letohl(tvb, offset)
- : tvb_get_ntohl(tvb, offset);
+ value = (encoding & ENC_LITTLE_ENDIAN) ? tvb_get_letohl(tvb, offset)
+ : tvb_get_ntohl(tvb, offset);
}
report_type_length_mismatch(tree, "an unsigned integer", length, length_error);
break;
}
report_type_length_mismatch(tree, "an unsigned integer", length, length_error);
break;
report_type_length_mismatch(tree, "an IPXNET address", length, length_error);
}
proto_tree_set_ipxnet(new_fi,
report_type_length_mismatch(tree, "an IPXNET address", length, length_error);
}
proto_tree_set_ipxnet(new_fi,
- get_uint_value(tree, tvb, start, FT_IPXNET_LEN, FALSE));
+ get_uint_value(tree, tvb, start, FT_IPXNET_LEN, ENC_BIG_ENDIAN));
*/
static void
test_length(header_field_info *hfinfo, proto_tree *tree, tvbuff_t *tvb,
*/
static void
test_length(header_field_info *hfinfo, proto_tree *tree, tvbuff_t *tvb,
- gint start, gint length, gboolean little_endian)
+ gint start, gint length, const guint encoding)
if (hfinfo->type == FT_UINT_BYTES || hfinfo->type == FT_UINT_STRING) {
guint32 n;
if (hfinfo->type == FT_UINT_BYTES || hfinfo->type == FT_UINT_STRING) {
guint32 n;
- n = get_uint_value(tree, tvb, start, length, little_endian);
+ n = get_uint_value(tree, tvb, start, length, encoding);
if (n > size + n) {
/* If n > size + n then we have an integer overflow, so
* set size to -1, which will force the
if (n > size + n) {
/* If n > size + n then we have an integer overflow, so
* set size to -1, which will force the