bus error in argus_dlpi 2.0.6

Carter Bullard carter at qosient.com
Wed Dec 10 11:37:41 EST 2003


Hey William,
   There is code to align the packets, if its
needed.  I may have messed something up, so let
me look into it.  Is this the release candidate
code?

Carter


-----Original Message-----
From: owner-argus-info at lists.andrew.cmu.edu
[mailto:owner-argus-info at lists.andrew.cmu.edu] On Behalf Of William Setzer
Sent: Wednesday, December 10, 2003 10:13 AM
To: argus at lists.andrew.cmu.edu
Subject: bus error in argus_dlpi 2.0.6


Under Solaris 8 and compiled with gcc 2.9.5, for some reason the
variables `oip' and `icmp' in the following bit of the argus
server (Argus_icmp.c, lines 197-201, the 2.0.6 RC):

            struct ip *oip = &icmp->icmp_ip;

            icmpObj->isrcaddr  = ntohl(oip->ip_src.s_addr);
            icmpObj->idstaddr  = ntohl(oip->ip_dst.s_addr);
            icmpObj->igwaddr   = ntohl(icmp->icmp_gwaddr.s_addr);

can sometimes be misaligned and put on a 2 byte boundary instead
of a 4 byte boundary, and so cause a bus error on lines 199-201
when accessed.

I tried compiling both with and without optimization, and also
tried moving the two variables around in the source, but neither
worked.  This patch seems to work, but is exceedingly cheesy:

--- Argus_icmp.c.orig	2003-03-26 23:11:13.000001000 -0500
+++ Argus_icmp.c	2003-12-09 17:00:49.000026000 -0500
@@ -195,10 +195,16 @@
             }
          } else {
             struct ip *oip = &icmp->icmp_ip;
-
-            icmpObj->isrcaddr  = ntohl(oip->ip_src.s_addr);
-            icmpObj->idstaddr  = ntohl(oip->ip_dst.s_addr);
-            icmpObj->igwaddr   = ntohl(icmp->icmp_gwaddr.s_addr);
+            struct icmp *oicmp = icmp;
+            struct ip oipcopy;
+            struct icmp oicmpcopy;
+
+            bcopy((char *)oip, (char *)&oipcopy, sizeof(struct ip));
+            bcopy((char *)oicmp, (char *)&oicmpcopy, sizeof(struct icmp));
+
+            icmpObj->isrcaddr  = ntohl(oipcopy.ip_src.s_addr);
+            icmpObj->idstaddr  = ntohl(oipcopy.ip_dst.s_addr);
+            icmpObj->igwaddr   = ntohl(oicmpcopy.icmp_gwaddr.s_addr);
          }
       }
    } else {

I'm afraid it's been so long since I've done any C that I've lost
any idea how to do this properly.  I'll leave it up to the experts
then. :)


William






More information about the argus mailing list