From f93c76fd10c0899a5ce6b8eae5009c5b374cdbd8 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Thu, 26 Aug 1999 07:34:43 +0000 Subject: [PATCH] Convert a bunch of uses of "fd->cap_len" to use "pi.captured_len" (or to use END_OF_FRAME), so that they don't look at stuff in an IP datagram past the end of the IP datagram (i.e., frame padding). svn path=/trunk/; revision=584 --- packet-bootp.c | 4 ++-- packet-giop.c | 8 ++++---- packet-gre.c | 4 ++-- packet-isakmp.c | 4 ++-- packet-ospf.c | 22 +++++++++++----------- packet-pptp.c | 4 ++-- packet-rip.c | 6 +++--- packet-smb.c | 4 ++-- 8 files changed, 28 insertions(+), 28 deletions(-) diff --git a/packet-bootp.c b/packet-bootp.c index 94d13636f3..d24ba465ae 100644 --- a/packet-bootp.c +++ b/packet-bootp.c @@ -2,7 +2,7 @@ * Routines for BOOTP/DHCP packet disassembly * Gilbert Ramirez * - * $Id: packet-bootp.c,v 1.18 1999/07/29 05:46:52 gram Exp $ + * $Id: packet-bootp.c,v 1.19 1999/08/26 07:34:43 guy Exp $ * * The information used comes from: * RFC 2132: DHCP Options and BOOTP Vendor Extensions @@ -517,7 +517,7 @@ dissect_bootp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) } voff = offset+240; - eoff = fd->cap_len; + eoff = pi.captured_len; while (voff < eoff) { voff += bootp_option(pd, bp_tree, voff, eoff); diff --git a/packet-giop.c b/packet-giop.c index 45558b667b..feae91679d 100644 --- a/packet-giop.c +++ b/packet-giop.c @@ -3,7 +3,7 @@ * * Laurent Deniel * - * $Id: packet-giop.c,v 1.4 1999/07/29 05:46:54 gram Exp $ + * $Id: packet-giop.c,v 1.5 1999/08/26 07:34:42 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -211,7 +211,7 @@ void dissect_giop(const u_char *pd, int offset, frame_data *fd, proto_tree *tree #define END_OF_GIOP_MESSAGE (offset - first_offset - GIOP_HEADER_SIZE) - if (fd->cap_len < offset + GIOP_HEADER_SIZE) { + if (pi.captured_len < offset + GIOP_HEADER_SIZE) { dissect_data(pd, offset, fd, tree); return; } @@ -304,7 +304,7 @@ void dissect_giop(const u_char *pd, int offset, frame_data *fd, proto_tree *tree offset += GIOP_HEADER_SIZE; - if (fd->cap_len < offset + message_size) { + if (pi.captured_len < offset + message_size) { dissect_data(pd, offset, fd, tree); return; } @@ -691,7 +691,7 @@ void dissect_giop(const u_char *pd, int offset, frame_data *fd, proto_tree *tree offset = first_offset + GIOP_HEADER_SIZE + message_size; - if (offset < fd->cap_len) { + if (offset < pi.captured_len) { dissect_data(pd, offset, fd, tree); } diff --git a/packet-gre.c b/packet-gre.c index 21d3b02ef4..9a6a57fbd7 100644 --- a/packet-gre.c +++ b/packet-gre.c @@ -2,7 +2,7 @@ * Routines for the Generic Routing Encapsulation (GRE) protocol * Brad Robel-Forrest * - * $Id: packet-gre.c,v 1.4 1999/07/29 05:46:55 gram Exp $ + * $Id: packet-gre.c,v 1.5 1999/08/26 07:34:42 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -77,7 +77,7 @@ dissect_gre(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) { col_add_str(fd, COL_INFO, "Encapsulated unknown"); } - if (fd->cap_len > offset && tree) { + if (pi.captured_len > offset && tree) { int is_ppp; proto_item * ti; proto_tree * gre_tree; diff --git a/packet-isakmp.c b/packet-isakmp.c index c6267a0904..65867c86da 100644 --- a/packet-isakmp.c +++ b/packet-isakmp.c @@ -2,7 +2,7 @@ * Routines for the Internet Security Association and Key Management Protocol (ISAKMP) * Brad Robel-Forrest * - * $Id: packet-isakmp.c,v 1.7 1999/07/29 05:46:57 gram Exp $ + * $Id: packet-isakmp.c,v 1.8 1999/08/26 07:34:41 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -289,7 +289,7 @@ void dissect_isakmp(const u_char *pd, int offset, frame_data *fd, proto_tree *tr if (check_col(fd, COL_INFO)) col_add_fstr(fd, COL_INFO, "%s", exchtype2str(hdr->exch_type)); - if (fd->cap_len > offset && tree) { + if (pi.captured_len > offset && tree) { proto_item * ti; proto_tree * isakmp_tree; diff --git a/packet-ospf.c b/packet-ospf.c index fe5d6f0d7a..6848f4c01e 100644 --- a/packet-ospf.c +++ b/packet-ospf.c @@ -2,7 +2,7 @@ * Routines for OSPF packet disassembly * (c) Copyright Hannes R. Boehm * - * $Id: packet-ospf.c,v 1.12 1999/07/29 05:47:01 gram Exp $ + * $Id: packet-ospf.c,v 1.13 1999/08/26 07:34:41 guy Exp $ * * At this time, this module is able to analyze OSPF * packets as specified in RFC2328. MOSPF (RFC1584) and other @@ -162,7 +162,7 @@ dissect_ospf_hello(const u_char *pd, int offset, frame_data *fd, proto_tree *tre memcpy(&ospfhello, &pd[offset], sizeof(e_ospf_hello)); if (tree) { - ti = proto_tree_add_text(tree, offset, (fd->cap_len - offset) , "OSPF Hello Packet"); + ti = proto_tree_add_text(tree, offset, END_OF_FRAME, "OSPF Hello Packet"); ospf_hello_tree = proto_item_add_subtree(ti, ETT_OSPF_HELLO); @@ -200,8 +200,8 @@ dissect_ospf_hello(const u_char *pd, int offset, frame_data *fd, proto_tree *tre offset+=20; - while(((int)(fd->cap_len - offset)) >= 4){ - printf("%d", fd->cap_len - offset); + while(((int)(pi.captured_len - offset)) >= 4){ + printf("%d", pi.captured_len - offset); ospfneighbor=(guint32 *) &pd[offset]; proto_tree_add_text(ospf_hello_tree, offset, 4, "Active Neighbor: %s", ip_to_str((guint8 *) ospfneighbor)); offset+=4; @@ -223,7 +223,7 @@ dissect_ospf_db_desc(const u_char *pd, int offset, frame_data *fd, proto_tree *t memcpy(&ospf_dbd, &pd[offset], sizeof(e_ospf_dbd)); if (tree) { - ti = proto_tree_add_text(tree, offset, (fd->cap_len - offset) , "OSPF DB Description"); + ti = proto_tree_add_text(tree, offset, END_OF_FRAME, "OSPF DB Description"); ospf_db_desc_tree = proto_item_add_subtree(ti, ETT_OSPF_DESC); proto_tree_add_text(ospf_db_desc_tree, offset, 2, "Interface MTU: %d", ntohs(ospf_dbd.interface_mtu) ); @@ -274,7 +274,7 @@ dissect_ospf_db_desc(const u_char *pd, int offset, frame_data *fd, proto_tree *t /* LS Headers will be processed here */ /* skip to the end of DB-Desc header */ offset+=8; - while( ((int) (fd->cap_len - offset)) >= OSPF_LSA_HEADER_LENGTH ) { + while( ((int) (pi.captured_len - offset)) >= OSPF_LSA_HEADER_LENGTH ) { dissect_ospf_lsa(pd, offset, fd, tree, FALSE); offset+=OSPF_LSA_HEADER_LENGTH; } @@ -291,7 +291,7 @@ dissect_ospf_ls_req(const u_char *pd, int offset, frame_data *fd, proto_tree *tr /* zero or more LS requests may be within a LS Request */ /* we place every request for a LSA in a single subtree */ if (tree) { - while( ((int) ( fd->cap_len - offset)) >= OSPF_LS_REQ_LENGTH ){ + while( ((int) (pi.captured_len - offset)) >= OSPF_LS_REQ_LENGTH ){ memcpy(&ospf_lsr, &pd[offset], sizeof(e_ospf_ls_req)); ti = proto_tree_add_text(tree, offset, OSPF_LS_REQ_LENGTH, "Link State Request"); ospf_lsr_tree = proto_item_add_subtree(ti, ETT_OSPF_LSR); @@ -342,7 +342,7 @@ dissect_ospf_ls_upd(const u_char *pd, int offset, frame_data *fd, proto_tree *tr memcpy(&upd_hdr, &pd[offset], sizeof(e_ospf_lsa_upd_hdr)); if (tree) { - ti = proto_tree_add_text(tree, offset, (fd->cap_len - offset) , "LS Update Packet"); + ti = proto_tree_add_text(tree, offset, END_OF_FRAME, "LS Update Packet"); ospf_lsa_upd_tree = proto_item_add_subtree(ti, ETT_OSPF_LSA_UPD); proto_tree_add_text(ospf_lsa_upd_tree, offset, 4, "Nr oF LSAs: %ld", (long)ntohl(upd_hdr.lsa_nr) ); @@ -361,7 +361,7 @@ void dissect_ospf_ls_ack(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) { /* the body of a LS Ack packet simply contains zero or more LSA Headers */ - while( ((int)(fd->cap_len - offset)) >= OSPF_LSA_HEADER_LENGTH ) { + while( ((int)(pi.captured_len - offset)) >= OSPF_LSA_HEADER_LENGTH ) { dissect_ospf_lsa(pd, offset, fd, tree, FALSE); offset+=OSPF_LSA_HEADER_LENGTH; } @@ -523,7 +523,7 @@ dissect_ospf_lsa(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, ip_to_str((guint8 *) &(network_lsa.network_mask))); offset += 4; - while( ((int) (fd->cap_len - offset)) >= 4){ + while( ((int) (pi.captured_len - offset)) >= 4){ attached_router = (guint32 *) &pd[offset]; proto_tree_add_text(ospf_lsa_tree, offset, 4, "Attached Router: %s", ip_to_str((guint8 *) attached_router)); @@ -567,7 +567,7 @@ dissect_ospf_lsa(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, break; default: /* unknown LSA type */ - proto_tree_add_text(ospf_lsa_tree, offset, (fd->cap_len - offset), "Unknown LSA Type"); + proto_tree_add_text(ospf_lsa_tree, offset, END_OF_FRAME, "Unknown LSA Type"); } } /* return the length of this LSA */ diff --git a/packet-pptp.c b/packet-pptp.c index a29f2c18a1..376434ab1a 100644 --- a/packet-pptp.c +++ b/packet-pptp.c @@ -2,7 +2,7 @@ * Routines for the Point-to-Point Tunnelling Protocol (PPTP) * Brad Robel-Forrest * - * $Id: packet-pptp.c,v 1.3 1999/07/13 02:52:53 gram Exp $ + * $Id: packet-pptp.c,v 1.4 1999/08/26 07:34:40 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -390,7 +390,7 @@ dissect_pptp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) { if (check_col(fd, COL_INFO)) col_add_fstr(fd, COL_INFO, "%s", cntrltype2str(cntrl_type)); - if (fd->cap_len > offset && tree) { + if (pi.captured_len > offset && tree) { guint16 msg_type; proto_item * ti; proto_tree * pptp_tree; diff --git a/packet-rip.c b/packet-rip.c index c2fa6c7f89..f81efc48fc 100644 --- a/packet-rip.c +++ b/packet-rip.c @@ -2,7 +2,7 @@ * Routines for RIPv1 and RIPv2 packet disassembly * (c) Copyright Hannes R. Boehm * - * $Id: packet-rip.c,v 1.11 1999/08/04 00:33:11 guy Exp $ + * $Id: packet-rip.c,v 1.12 1999/08/26 07:34:40 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -92,7 +92,7 @@ dissect_rip(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) { col_add_str(fd, COL_INFO, packet_type[rip_header.command]); if (tree) { - ti = proto_tree_add_item(tree, proto_rip, offset, (fd->cap_len - offset), NULL); + ti = proto_tree_add_item(tree, proto_rip, offset, END_OF_FRAME, NULL); rip_tree = proto_item_add_subtree(ti, ETT_RIP); proto_tree_add_text(rip_tree, offset, 1, "Command: %d (%s)", rip_header.command, packet_type[rip_header.command]); @@ -105,7 +105,7 @@ dissect_rip(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) { /* zero or more entries */ - while((fd->cap_len - offset) >= RIP_ENTRY_LENGTH){ + while((pi.captured_len - offset) >= RIP_ENTRY_LENGTH){ memcpy(&rip_entry, &pd[offset], sizeof(rip_entry)); /* avoid alignment problem */ family = ntohs(rip_entry.vektor.family); switch (family) { diff --git a/packet-smb.c b/packet-smb.c index 82acd5b120..98b5aca784 100644 --- a/packet-smb.c +++ b/packet-smb.c @@ -2,7 +2,7 @@ * Routines for smb packet dissection * Copyright 1999, Richard Sharpe * - * $Id: packet-smb.c,v 1.23 1999/08/24 17:26:14 gram Exp $ + * $Id: packet-smb.c,v 1.24 1999/08/26 07:34:38 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -1444,7 +1444,7 @@ dissect_negprot_smb(const u_char *pd, int offset, frame_data *fd, proto_tree *tr } - while (fd->cap_len > offset) { + while (pi.captured_len > offset) { const char *str; if (tree) {