Error compiling syslog-ng 2.0.1 on Solaris, Bug in dnscache.c
I tried to compile syslog-ng 2.0.1 on a Solaris 10-machine, but gcc exits with an error: [...] dnscache.c: In function `dns_cache_key_hash': dnscache.c:82: error: structure has no member named `s6_addr32' dnscache.c:82: error: structure has no member named `s6_addr32' dnscache.c:82: error: structure has no member named `s6_addr32' dnscache.c:82: error: structure has no member named `s6_addr32' make[2]: *** [dnscache.o] Error 1 [...] So I took a look at line 80 in dnsache.c: return (0x80000000 | (e->addr.ip6.s6_addr32[0] ^ e->addr.ip6.s6_addr32[2] ^ e->addr.ip6.s6_addr32[3] ^ e->addr.ip6.s6_addr32[4])); e is a _DNSCacheKey: struct _DNSCacheKey { gint family; union { struct in_addr ip; struct in6_addr ip6; } addr; }; in6_addr comes from /usr/include/netinet/in.h: struct in6_addr { union { #ifdef _KERNEL uint32_t _S6_u32[4]; /* IPv6 address */ uint8_t _S6_u8[16]; /* IPv6 address */ #else uint8_t _S6_u8[16]; /* IPv6 address */ uint32_t _S6_u32[4]; /* IPv6 address */ #endif uint32_t __S6_align; /* Align on 32 bit boundary */ } _S6_un; }; #define s6_addr _S6_un._S6_u8 #ifdef _KERNEL #define s6_addr8 _S6_un._S6_u8 #define s6_addr32 _S6_un._S6_u32 #endif As we are not compiling Kernel-Modules, macro _KERNEL is not defined, so gcc cannot find the member s6_addr32. So I had to modify dnscache.c: tb@host:~/src/syslog-ng-2.0.1 $ vi +80 src/dnscache.c #define s6_addr32 _S6_un._S6_u32 static guint dns_cache_key_hash(DNSCacheKey *e) { if (e->family == AF_INET) return ntohl(e->addr.ip.s_addr); else return (0x80000000 | (e->addr.ip6.s6_addr32[0] ^ e->addr.ip6.s6_addr32[1] ^ e->addr.ip6.s6_addr32[2] ^ e->addr.ip6.s6_addr32[3])); } Among this, s6_addr32 is defined as an array with 4 elements, but you are requesting elements 0, 2, 3 and 4 - this will produce a core dump! I corrected this. The problem with the missing macro exists on Solaris 8 and 9 also, this is fine on Linux. A patch would be fine!
On Thu, 2007-01-04 at 15:30 +0100, Thomas Blank wrote:
I tried to compile syslog-ng 2.0.1 on a Solaris 10-machine, but gcc exits with an error:
[...] dnscache.c: In function `dns_cache_key_hash': dnscache.c:82: error: structure has no member named `s6_addr32' dnscache.c:82: error: structure has no member named `s6_addr32' dnscache.c:82: error: structure has no member named `s6_addr32' dnscache.c:82: error: structure has no member named `s6_addr32' make[2]: *** [dnscache.o] Error 1 [...]
Can you test this patch? --- orig/src/dnscache.c +++ mod/src/dnscache.c @@ -75,9 +75,14 @@ static guint dns_cache_key_hash(DNSCacheKey *e) { if (e->family == AF_INET) - return ntohl(e->addr.ip.s_addr); + { + return ntohl(e->addr.ip.s_addr); + } else - return (0x80000000 | (e->addr.ip6.s6_addr32[0] ^ e->addr.ip6.s6_addr32[2] ^ e->addr.ip6.s6_addr32[3] ^ e->addr.ip6.s6_addr32[4])); + { + guint32 *a32 = (guint32 *) &e->addr.ip6.s6_addr; + return (0x80000000 | (a32[0] ^ a32[1] ^ a32[2] ^ a32[3])); + } } static inline void -- Bazsi
Your patch works. Do you patch the sources? Thomas Balazs Scheidler <bazsi@balab An it.hu> Syslog-ng users' and developers' mailing list Gesendet <syslog-ng@lists.balabit.hu> von: Kopie syslog-ng-bo unces@lists. Thema balabit.hu Re: [syslog-ng] Error compiling syslog-ng 2.0.1 on Solaris, Bug in dnscache.c 07.01.2007 17:43 Bitte antworten an Syslog-ng users' and developers' mailing list <syslog-ng@l ists.balabit .hu> On Thu, 2007-01-04 at 15:30 +0100, Thomas Blank wrote:
I tried to compile syslog-ng 2.0.1 on a Solaris 10-machine, but gcc exits with an error:
[...] dnscache.c: In function `dns_cache_key_hash': dnscache.c:82: error: structure has no member named `s6_addr32' dnscache.c:82: error: structure has no member named `s6_addr32' dnscache.c:82: error: structure has no member named `s6_addr32' dnscache.c:82: error: structure has no member named `s6_addr32' make[2]: *** [dnscache.o] Error 1 [...]
Can you test this patch? --- orig/src/dnscache.c +++ mod/src/dnscache.c @@ -75,9 +75,14 @@ static guint dns_cache_key_hash(DNSCacheKey *e) { if (e->family == AF_INET) - return ntohl(e->addr.ip.s_addr); + { + return ntohl(e->addr.ip.s_addr); + } else - return (0x80000000 | (e->addr.ip6.s6_addr32[0] ^ e->addr.ip6.s6_addr32[2] ^ e->addr.ip6.s6_addr32[3] ^ e->addr.ip6.s6_addr32[4])); + { + guint32 *a32 = (guint32 *) &e->addr.ip6.s6_addr; + return (0x80000000 | (a32[0] ^ a32[1] ^ a32[2] ^ a32[3])); + } } static inline void -- Bazsi _______________________________________________ syslog-ng maillist - syslog-ng@lists.balabit.hu https://lists.balabit.hu/mailman/listinfo/syslog-ng Frequently asked questions at http://www.campin.net/syslog-ng/faq.html
On Mon, 2007-01-08 at 10:04 +0100, Thomas Blank wrote:
Your patch works. Do you patch the sources?
I have committed the change, if that was what you asked. It should be available as snapshot. -- Bazsi
participants (2)
-
Balazs Scheidler
-
Thomas Blank