Ethereal-dev: [ethereal-dev] Patch for unaligned accesses on Digital UNIX (1)

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

Date Next Thread Next
From: Laurent Deniel <deniel@xxxxxxxxxxx>
Date: Tue, 01 Sep 1998 18:12:16 +0200
Hi,

 The attached diff file contains a patch that fixes an
 unaligned access for RIP packets on Digital UNIX.
 The other common protocols (e.g. TCP, UDP) seem to
 be correctly handled (the offset should be already
 multiple of 8 in many cases).
 I will continue to check that out.

 Laurent.

--
Laurent DENIEL            | E-mail: deniel@xxxxxxxxxxx
Paris, FRANCE             |         deniel@xxxxxxxxxxxxxxxxxxxxxxxxxxxx
                          | WWW   : http://www.worldnet.fr/~deniel
    All above opinions are personal, unless stated otherwise.
--- ethereal-0.3.13/packet-rip.c	Sun Aug 30 18:00:07 1998
+++ ethereal-0.3.14/packet-rip.c	Tue Sep  1 08:47:20 1998
@@ -44,7 +44,7 @@
 void 
 dissect_rip(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
     e_riphdr *rip_header;
-    e_rip_vektor *rip_vektor;
+    e_rip_vektor rip_vektor;
     int auth = FALSE;
 
     GtkWidget *rip_tree = NULL, *ti; 
@@ -126,17 +126,17 @@
             rip_vektor_tree = gtk_tree_new(); 
             add_subtree(ti, rip_vektor_tree, ETT_RIP_VEC);
 	   
-            rip_vektor = (e_rip_vektor *) &pd[offset]; 
-            add_item_to_tree(rip_vektor_tree, offset, 4, "IP Address: %s", ip_to_str((guint8 *) &(rip_vektor->ip))); 
+            memcpy(&rip_vektor, &pd[offset], sizeof(rip_vektor)); /* avoid alignment problem */
+            add_item_to_tree(rip_vektor_tree, offset, 4, "IP Address: %s", ip_to_str((guint8 *) &(rip_vektor.ip))); 
 
 	    if(rip_header->version == RIPv2) {
                 add_item_to_tree(rip_vektor_tree, offset + 4 , 4, "Netmask: %s", 
-		                                      ip_to_str((guint8 *) &(rip_vektor->mask))); 
+		                                      ip_to_str((guint8 *) &(rip_vektor.mask))); 
                 add_item_to_tree(rip_vektor_tree, offset + 8 , 4, "Next Hop: %s", 
-		                                      ip_to_str((guint8 *) &(rip_vektor->next_hop))); 
+		                                      ip_to_str((guint8 *) &(rip_vektor.next_hop))); 
             }
 
-            add_item_to_tree(rip_vektor_tree, offset + 12 , 4, "Metric: %d", ntohl(rip_vektor->metric)); 
+            add_item_to_tree(rip_vektor_tree, offset + 12 , 4, "Metric: %d", ntohl(rip_vektor.metric)); 
 
             offset += RIP_VEKTOR_LENGTH;
         };