[syslog-ng] Error compiling syslog-ng 2.0.1 on Solaris,
Bug in dnscache.c
Thomas Blank
Thomas.Blank at de.debitel.com
Thu Jan 4 15:30:43 CET 2007
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 at 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!
More information about the syslog-ng
mailing list