aboutsummaryrefslogtreecommitdiffstats
path: root/epan/proto.c
diff options
context:
space:
mode:
authorDario Lombardo <lomato@gmail.com>2019-01-11 12:24:46 +0100
committerAnders Broman <a.broman58@gmail.com>2019-01-13 07:12:43 +0000
commit82326d21fd43f2e544630bbdd88d1df4540c7cc9 (patch)
treef74cac65b9d3a119bf9be54d082b2cc11785b113 /epan/proto.c
parente984cdeb22d5f024d3cbfd0ae05a8bde315c91f8 (diff)
proto: ensure valid width through assert.
Found by scan-build. Change-Id: I467e56bfa4f20f5c87efa47823d54691503de318 Reviewed-on: https://code.wireshark.org/review/31486 Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/proto.c')
-rw-r--r--epan/proto.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/epan/proto.c b/epan/proto.c
index b781a775fa..0cbd6bfddb 100644
--- a/epan/proto.c
+++ b/epan/proto.c
@@ -4609,7 +4609,6 @@ proto_tree_set_boolean(field_info *fi, guint64 value)
/* Generate, into "buf", a string showing the bits of a bitfield.
Return a pointer to the character after that string. */
-/*XXX this needs a buf_len check */
static char *
other_decode_bitfield_value(char *buf, const guint64 val, const guint64 mask, const int width)
{
@@ -4619,6 +4618,10 @@ other_decode_bitfield_value(char *buf, const guint64 val, const guint64 mask, co
i = 0;
p = buf;
+
+ /* This is a devel error. It is safer to stop here. */
+ DISSECTOR_ASSERT(width >= 1);
+
bit = G_GUINT64_CONSTANT(1) << (width - 1);
for (;;) {
if (mask & bit) {