aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--packet-nbipx.c12
-rw-r--r--packet-nbns.c23
-rw-r--r--packet-netbios.c27
-rw-r--r--packet-netbios.h6
4 files changed, 37 insertions, 31 deletions
diff --git a/packet-nbipx.c b/packet-nbipx.c
index 0f36201313..81092ae76f 100644
--- a/packet-nbipx.c
+++ b/packet-nbipx.c
@@ -2,7 +2,7 @@
* Routines for NetBIOS over IPX packet disassembly
* Gilbert Ramirez <gram@xiexie.org>
*
- * $Id: packet-nbipx.c,v 1.39 2001/09/28 22:43:56 guy Exp $
+ * $Id: packet-nbipx.c,v 1.40 2001/09/29 00:57:35 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -222,6 +222,7 @@ dissect_nbipx(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
char name[(NETBIOS_NAME_LEN - 1)*4 + 1];
int name_type;
gboolean has_payload;
+ tvbuff_t *next_tvb;
if (check_col(pinfo->fd, COL_PROTOCOL))
col_set_str(pinfo->fd, COL_PROTOCOL, "NBIPX");
@@ -466,8 +467,8 @@ dissect_nbipx(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
proto_item_set_len(ti, offset);
if (has_payload && tvb_offset_exists(tvb, offset)) {
- dissect_netbios_payload(tvb, offset, pinfo, tree,
- tvb_length_remaining(tvb, offset));
+ next_tvb = tvb_new_subset(tvb, offset, -1, -1);
+ dissect_netbios_payload(next_tvb, pinfo, tree);
}
}
@@ -674,6 +675,7 @@ dissect_nmpi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
int name_type;
char node_name[(NETBIOS_NAME_LEN - 1)*4 + 1];
int node_name_type = 0;
+ tvbuff_t *next_tvb;
if (check_col(pinfo->fd, COL_PROTOCOL))
col_set_str(pinfo->fd, COL_PROTOCOL, "NMPI");
@@ -767,8 +769,8 @@ dissect_nmpi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
offset += 1 + 1 + 2 + NETBIOS_NAME_LEN + NETBIOS_NAME_LEN;
if (opcode == IMSLOT_SEND && tvb_offset_exists(tvb, offset)) {
- dissect_netbios_payload(tvb, offset, pinfo, tree,
- tvb_length_remaining(tvb, offset));
+ next_tvb = tvb_new_subset(tvb, offset, -1, -1);
+ dissect_netbios_payload(next_tvb, pinfo, tree);
}
}
diff --git a/packet-nbns.c b/packet-nbns.c
index 986faf0705..c0694fb1d4 100644
--- a/packet-nbns.c
+++ b/packet-nbns.c
@@ -4,7 +4,7 @@
* Gilbert Ramirez <gram@xiexie.org>
* Much stuff added by Guy Harris <guy@alum.mit.edu>
*
- * $Id: packet-nbns.c,v 1.58 2001/09/29 00:00:26 guy Exp $
+ * $Id: packet-nbns.c,v 1.59 2001/09/29 00:57:36 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -1158,7 +1158,6 @@ dissect_nbdgm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
int msglen;
int flags;
int message_index;
- int max_data = tvb_length_remaining(tvb, offset);
tvbuff_t *next_tvb;
static const value_string error_codes[] = {
@@ -1241,7 +1240,6 @@ dissect_nbdgm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
}
offset += 10;
- max_data -= 10;
switch (header.msg_type) {
@@ -1256,7 +1254,6 @@ dissect_nbdgm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
}
offset += 4;
- max_data -= 4;
/* Source name */
len = get_nbns_name(tvb, offset, offset, name, &name_type);
@@ -1266,7 +1263,6 @@ dissect_nbdgm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
"Source name", name, name_type);
}
offset += len;
- max_data -= len;
/* Destination name */
len = get_nbns_name(tvb, offset, offset, name, &name_type);
@@ -1276,7 +1272,6 @@ dissect_nbdgm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
"Destination name", name, name_type);
}
offset += len;
- max_data -= len;
/*
* Here we can pass the packet off to the next protocol.
@@ -1284,7 +1279,8 @@ dissect_nbdgm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
* only our stuff.
*/
proto_item_set_len(ti, offset);
- dissect_netbios_payload(tvb, offset, pinfo, tree, max_data);
+ next_tvb = tvb_new_subset(tvb, offset, -1, -1);
+ dissect_netbios_payload(next_tvb, pinfo, tree);
break;
case NBDS_ERROR:
@@ -1374,6 +1370,8 @@ dissect_nbss_packet(tvbuff_t *tvb, int offset, packet_info *pinfo,
int len;
char name[(NETBIOS_NAME_LEN - 1)*4 + MAXDNAME];
int name_type;
+ gint reported_len;
+ tvbuff_t *next_tvb;
msg_type = tvb_get_guint8(tvb, offset);
@@ -1484,12 +1482,19 @@ dissect_nbss_packet(tvbuff_t *tvb, int offset, packet_info *pinfo,
case SESSION_MESSAGE:
/*
- * Here we can pass the packet off to the next protocol.
+ * Here we can pass the message off to the next protocol.
* Set the length of our top-level tree item to include
* only our stuff.
*/
proto_item_set_len(ti, offset);
- dissect_netbios_payload(tvb, offset, pinfo, tree, length);
+ len = tvb_length_remaining(tvb, offset);
+ reported_len = tvb_reported_length_remaining(tvb, offset);
+ if (len > length)
+ len = length;
+ if (reported_len > length)
+ reported_len = length;
+ next_tvb = tvb_new_subset(tvb, offset, len, reported_len);
+ dissect_netbios_payload(next_tvb, pinfo, tree);
break;
}
diff --git a/packet-netbios.c b/packet-netbios.c
index d21144ab86..c1671faee0 100644
--- a/packet-netbios.c
+++ b/packet-netbios.c
@@ -5,7 +5,7 @@
*
* derived from the packet-nbns.c
*
- * $Id: packet-netbios.c,v 1.36 2001/09/28 22:43:56 guy Exp $
+ * $Id: packet-netbios.c,v 1.37 2001/09/29 00:57:36 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -957,20 +957,17 @@ void (*dissect_netb[])(tvbuff_t *, int, proto_tree *) = {
static heur_dissector_list_t netbios_heur_subdissector_list;
void
-dissect_netbios_payload(tvbuff_t *tvb, int offset, packet_info *pinfo,
- proto_tree *tree, int max_data)
+dissect_netbios_payload(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
- tvbuff_t *next_tvb;
- const guint8 *next_pd;
- int next_offset;
-
- next_tvb = tvb_new_subset(tvb, offset, -1, -1);
+ const guint8 *pd;
+ int offset;
+ int max_data;
/*
* Try the heuristic dissectors for NetBIOS.
*/
if (dissector_try_heuristic(netbios_heur_subdissector_list,
- next_tvb, pinfo, tree))
+ tvb, pinfo, tree))
return;
/*
@@ -978,15 +975,16 @@ dissect_netbios_payload(tvbuff_t *tvb, int offset, packet_info *pinfo,
* (XXX - once the SMB dissector is tvbuffified, it should
* become a regular heuristic dissector.)
*/
- tvb_compat(next_tvb, &next_pd, &next_offset);
+ tvb_compat(tvb, &pd, &offset);
+ max_data = tvb_length(tvb);
- if (dissect_smb(next_pd, next_offset, pinfo->fd, tree, max_data))
+ if (dissect_smb(pd, offset, pinfo->fd, tree, max_data))
return;
/*
* It's none of the above. Dissect it as data.
*/
- dissect_data(next_tvb, 0, pinfo, tree);
+ dissect_data(tvb, 0, pinfo, tree);
}
static void
@@ -998,6 +996,7 @@ dissect_netbios(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
guint16 hdr_len, command;
char name[(NETBIOS_NAME_LEN - 1)*4 + 1];
int name_type;
+ tvbuff_t *next_tvb;
int offset = 0;
@@ -1070,8 +1069,8 @@ dissect_netbios(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
offset += hdr_len; /* move past header */
- dissect_netbios_payload(tvb, offset, pinfo, tree,
- tvb_length_remaining(tvb, offset));
+ next_tvb = tvb_new_subset(tvb, offset, -1, -1);
+ dissect_netbios_payload(next_tvb, pinfo, tree);
}
diff --git a/packet-netbios.h b/packet-netbios.h
index a617f488ae..3b49807184 100644
--- a/packet-netbios.h
+++ b/packet-netbios.h
@@ -5,7 +5,7 @@
*
* derived from the packet-nbns.c
*
- * $Id: packet-netbios.h,v 1.10 2001/09/28 22:43:56 guy Exp $
+ * $Id: packet-netbios.h,v 1.11 2001/09/29 00:57:36 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -40,7 +40,7 @@ extern int get_netbios_name(tvbuff_t *tvb, int offset,
extern char *netbios_name_type_descr(int name_type);
extern void netbios_add_name( char* label, tvbuff_t *tvb, int offset,
proto_tree *tree);
-extern void dissect_netbios_payload(tvbuff_t *tvb, int offset,
- packet_info *pinfo, proto_tree *tree, int max_data);
+extern void dissect_netbios_payload(tvbuff_t *tvb, packet_info *pinfo,
+ proto_tree *tree);
#endif