[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Patch for unaligned access in smail



I'm posting the short patch here in the event that someone is eager to
apply it and upload a package.  Chris, would you rather do it?  Does
it matter?  I can easily upload the rev'd smail deb.  Let me know the
protocol.

diff --exclude=Makefile -u -r -b -B smail-3.2.0.102/pd/binmail/.Makefile smail-3.2.0.102-elf/pd/binmail/.Makefile
diff -u -r -b -B smail-3.2.0.102/src/hash.h smail-3.2.0.102-elf/src/hash.h
--- smail-3.2.0.102/src/hash.h	Wed Feb 28 06:26:30 1996
+++ smail-3.2.0.102-elf/src/hash.h	Thu Dec  3 22:58:47 1998
@@ -124,6 +124,13 @@
 #define keystr_len(keystring) \
   hash_align(strlen((char *)(keystring))+1)
 /* hash slot size in bytes - given lengths of the padded key string and data */
+     /* elf@buici.com 3 Dec 1998: this is overallocating 8 bytes on
+	alpha because it hash_aligns the keylength + 1.  It should
+	hash_align the OFFSET + keylength and add this to the
+	hash_align of datalen.  I leave this as is because I don't
+	want to spend the time to verify that there is reason other
+	than guesswork that the +1 is added.  This will always work,
+	but it will usually overallocate, too. */
 #define hashslot_size(keystrlen,datalen) \
  (hash_align(OFFSET(hash, keystr[0]) + \
 	     hash_align((int)(keystrlen)+1) + \
@@ -137,7 +143,8 @@
 /* pointer to hash data - given a ``struct hash'' element pointer */
 #define hash_data(cur) \
  ((((struct hash *)(cur))->datalen > 0) ? \
-  ((char *)(((struct hash *)(cur))->keystr+((struct hash *)(cur))->keylen)) :\
+  (((char*)(cur)) + hash_align (OFFSET (hash, keystr[0]) \
+				+ ((struct hash*)(cur))->keylen)) : \
   ((char *)NULL))
 
 /*

Reply to: