aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2005-03-29 22:23:09 +0000
committerGerald Combs <gerald@wireshark.org>2005-03-29 22:23:09 +0000
commit137d5a0fcd8207c68229fdcffcbd35747794e76f (patch)
tree5c5371e2c61f2652cd28c9a4b62eb5eb53eff6ba /epan
parentdfdd9ce19d830fdfeda7117457acb1b322993f33 (diff)
Add a tvb_ensure_bytes_exist() and fix a few other offset-related bugs.
svn path=/trunk/; revision=13974
Diffstat (limited to 'epan')
-rw-r--r--epan/dissectors/packet-isakmp.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/epan/dissectors/packet-isakmp.c b/epan/dissectors/packet-isakmp.c
index 646c5645c6..eff3d2baf9 100644
--- a/epan/dissectors/packet-isakmp.c
+++ b/epan/dissectors/packet-isakmp.c
@@ -332,7 +332,7 @@ dissect_payloads(tvbuff_t *tvb, proto_tree *tree, guint8 initial_payload,
proto_tree * ntree;
struct payload_func * f;
- for (payload = initial_payload; length != 0; payload = next_payload) {
+ for (payload = initial_payload; length > 0; payload = next_payload) {
if (payload == LOAD_TYPE_NONE) {
/*
* What? There's more stuff in this chunk of data, but the
@@ -348,6 +348,7 @@ dissect_payloads(tvbuff_t *tvb, proto_tree *tree, guint8 initial_payload,
if (ntree == NULL)
break;
if (payload_length >= 4) { /* XXX = > 4? */
+ tvb_ensure_bytes_exist(tvb, offset + 4, payload_length - 4);
if ((f = getpayload_func(payload)) != NULL && f->func != NULL)
(*f->func)(tvb, offset + 4, payload_length - 4, ntree, pinfo, -1);
else {
@@ -356,13 +357,13 @@ dissect_payloads(tvbuff_t *tvb, proto_tree *tree, guint8 initial_payload,
}
}
else if (payload_length > length) {
- proto_tree_add_text(ntree, tvb, offset + 4, 0,
+ proto_tree_add_text(ntree, tvb, 0, 0,
"Payload (bogus, length is %u, greater than remaining length %d",
payload_length, length);
return;
}
else {
- proto_tree_add_text(ntree, tvb, offset + 4, 0,
+ proto_tree_add_text(ntree, tvb, 0, 0,
"Payload (bogus, length is %u, must be at least 4)",
payload_length);
payload_length = 4;