Bug in irc_res.c

Immo 'FaUl' Wehrenberg immo at bundessicherheitsministerium.de
Tue Feb 7 12:13:52 EST 2006

I've invested a bit of time in investigating a bug which causes a
bus-error on any client-connect on some Platforms (in my case sparc64).
The problem is in res_readreply(), the buf is unaligned. The problem is
that some platforms (Sparc, Alpha and possible a few more require 
aligned Memory to access. In this case it's header->id, which is a
uint_16_t, that requires the uint_16_t to be aligned to 16 bits. 

Hovewer the following patch, not so nice though, fixes this (but depends
on gcc).


[Felix von Leitner in dcsm]
SuSE verscheuert eine Bastardisierung eines zusammenkopierten
Softwarehaufens, wo zufällig auch der Linux Kernel drin vorkommt.
-------------- next part --------------
diff -urp ircd-hybrid-7.2.0/src/irc_res.c ircd-hybrid-7.2.0.fixed/src/irc_res.c
--- ircd-hybrid-7.2.0/src/irc_res.c	2005-12-09 05:52:53.000000000 +0000
+++ ircd-hybrid-7.2.0.fixed/src/irc_res.c	2006-02-07 13:18:55.000000000 +0000
@@ -762,7 +762,15 @@ proc_answer(struct reslist *request, HEA
 static void
 res_readreply(fde_t *fd, void *data)
-  char buf[sizeof(HEADER) + MAXPACKET];
+  char buf[sizeof(HEADER) + MAXPACKET]
+	/* Sparc and alpha need 16bit-alignment for accessing header->id 
+	 * (which is uint16_t). Because of the header = (HEADER*) buf; 
+	 * lateron, this is neeeded. --FaUl
+	 */
+#if defined(__sparc__) || defined(__alpha__)  
+	  __attribute__((aligned (16)))
+	  ;
   HEADER *header;
   struct reslist *request = NULL;
   struct DNSReply *reply  = NULL;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.ircd-hybrid.org/pipermail/hybrid/attachments/20060207/7249ab46/attachment.pgp>

More information about the hybrid mailing list