Ethereal-dev: [ethereal-dev] Patch: OSPF Network-LSA dissection

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Heikki Vatiainen <hessu@xxxxxxxxx>
Date: Wed, 17 Nov 1999 18:09:38 +0200
While I was watching the OSPF database exchange between two
routers, I noticed that when Ethereal sees a Network-LSA it does
not stop dissecting the LSA until it hits the end of the packet.
The patch addresses this and fixes also two typos.

// Heikki

Index: ethereal/packet-ospf.c
===================================================================
RCS file: /cvsroot/ethereal/packet-ospf.c,v
retrieving revision 1.16
diff -u -r1.16 packet-ospf.c
--- packet-ospf.c	1999/11/16 11:42:45	1.16
+++ packet-ospf.c	1999/11/17 16:00:14
@@ -404,6 +404,7 @@
 dissect_ospf_lsa(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int disassemble_body) {
     e_ospf_lsa_hdr 	 lsa_hdr;
     char		*lsa_type;
+    int			 lsa_end;
 
     /* data strutures for the router LSA */
     e_ospf_router_lsa 		router_lsa;
@@ -440,7 +441,7 @@
 	    lsa_type="Network LSA";
             break;
         case OSPF_LSTYPE_SUMMERY:
-	    lsa_type="Summery LSA";
+	    lsa_type="Summary LSA";
             break;
         case OSPF_LSTYPE_ASBR:
 	    lsa_type="ASBR LSA";
@@ -481,7 +482,8 @@
            return OSPF_LSA_HEADER_LENGTH;
         }
 
-	/* the LSA body starts afte 20 bytes of LSA Header */
+	lsa_end = offset + ntohs(lsa_hdr.length);
+	/* the LSA body starts after 20 bytes of LSA Header */
 	offset+=20;
 
         switch(lsa_hdr.ls_type){
@@ -555,7 +557,7 @@
                                                  ip_to_str((guint8 *) &(network_lsa.network_mask)));
 		offset += 4;
 
-		while( ((int) (pi.captured_len - offset)) >= 4){
+		while( (lsa_end - 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));