Coda File System

Re: codasrv crash on netbsd/sparc64 3.0

From: Greg Troxel <gdt_at_ir.bbn.com>
Date: Tue, 25 Apr 2006 13:24:50 -0400
The code in rwcdb_pack.h doesn't check for alignment.
Try this:

--- rwcdb_pack.h.~1.4.~	2005-06-20 08:45:54.000000000 -0400
+++ rwcdb_pack.h	2006-04-25 13:24:23.000000000 -0400
@@ -59,6 +59,7 @@
 static __inline__ void packints(char *buf, const u_int32_t a, const u_int32_t b)
 {
     struct rwcdb_tuple *p = (struct rwcdb_tuple *)buf;
+    /* XXX alignment */
     p->a = SWAP_OUT(a);
     p->b = SWAP_OUT(b);
 }
@@ -66,8 +67,16 @@
 static __inline__ void unpackints(char *buf, u_int32_t *a, u_int32_t *b)
 {
     struct rwcdb_tuple *p = (struct rwcdb_tuple *)buf;
-    *a = SWAP_IN(p->a);
-    *b = SWAP_IN(p->b);
+    /* XXX cast is not right */
+    if ((long) p & 0x3) {
+      struct rwcdb_tuple t;
+      bcopy(&t, buf, sizeof(struct rwcdb_tuple));
+      *a = SWAP_IN(t.a);
+      *b = SWAP_IN(t.b);
+    } else {
+      *a = SWAP_IN(p->a);
+      *b = SWAP_IN(p->b);
+    }    
 }
 
 #endif /* _RWCDB_PACK_H_ */

-- 
        Greg Troxel <gdt_at_ir.bbn.com>
Received on 2006-04-25 13:26:12