Module: ngircd.git
Branch: master
Commit: 5b1efaee67044b56f6ecac1ee70883bfc61f8c5d
URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=5b1efaee…
Author: Alexander Barton <alex(a)barton.de>
Date: Mon Sep 14 01:23:19 2009 +0200
Check for sockaddr_in.sin_len and initialize it
Test for sockaddr_in.sin_len and initialize it to the correct value
which some systems (notably Mac OS X) require.
Note: this code path is only relevant when not using getaddrinfo().
---
configure.in | 6 +++++-
src/ipaddr/ng_ipaddr.c | 4 ++++
2 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/configure.in b/configure.in
index 567f216..bfa800b 100644
--- a/configure.in
+++ b/configure.in
@@ -1,6 +1,6 @@
#
# ngIRCd -- The Next Generation IRC Daemon
-# Copyright (c)2001-2008 Alexander Barton <alex(a)barton.de>
+# Copyright (c)2001-2009 Alexander Barton <alex(a)barton.de>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -33,6 +33,7 @@ AH_TEMPLATE([IRCPLUS], [Define if IRC+ protocol should be used])
AH_TEMPLATE([WANT_IPV6], [Define if IPV6 protocol should be enabled])
AH_TEMPLATE([ZEROCONF], [Define if support for Zeroconf should be included])
AH_TEMPLATE([IDENTAUTH], [Define if the server should do IDENT requests])
+AH_TEMPLATE([HAVE_sockaddr_in_len], [Define if sockaddr_in.sin_len exists])
AH_TEMPLATE([TARGET_OS], [Target operating system name])
AH_TEMPLATE([TARGET_VENDOR], [Target system vendor])
@@ -124,6 +125,9 @@ AC_TRY_COMPILE([
AC_TYPE_SIGNAL
AC_TYPE_SIZE_T
+AC_CHECK_MEMBER([struct sockaddr_in.sin_len], AC_DEFINE(HAVE_sockaddr_in_len),,
+ [#include <arpa/inet.h>])
+
# -- Libraries --
AC_CHECK_LIB(UTIL,memmove)
diff --git a/src/ipaddr/ng_ipaddr.c b/src/ipaddr/ng_ipaddr.c
index 0367a1f..4f1d4ca 100644
--- a/src/ipaddr/ng_ipaddr.c
+++ b/src/ipaddr/ng_ipaddr.c
@@ -51,6 +51,10 @@ ng_ipaddr_init(ng_ipaddr_t *addr, const char *ip_str, UINT16 port)
return ret == 0;
#else /* HAVE_GETADDRINFO */
assert(ip_str);
+ memset(addr, 0, sizeof *addr);
+#ifdef HAVE_sockaddr_in_len
+ addr->sin4.sin_len = sizeof(addr->sin4);
+#endif
addr->sin4.sin_family = AF_INET;
# ifdef HAVE_INET_ATON
if (inet_aton(ip_str, &addr->sin4.sin_addr) == 0)
Module: ngircd.git
Branch: master
Commit: d5f80b2a8deda30d0dcd69bea81a3ca862cf46ca
URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=d5f80b2a…
Author: Alexander Barton <alex(a)barton.de>
Date: Mon Sep 14 00:25:48 2009 +0200
Always use get{addr|name}info() when available
Both getaddrinfo() and getnameinfo() are now used always when available, and
not only when compiling ngIRCd with support for IPv6.
This not only enables ngIRCd to handle multiple addresses per hostname when
compiled without support for IPv6, but fixes binding ngIRCd to IP addresses
on Mac OS X (and probably other BSD-based systems) as well: these systems
require that sockaddr_in is zeroed out and sockaddr_in.sin_len is set to
sizeof(sockaddr_in) like that:
src/ipaddr/ng_ipaddr.c, line 54:
assert(ip_str);
+ memset(addr, 0, sizeof *addr);
+ addr->sin4.sin_len = sizeof(addr->sin4);
addr->sin4.sin_family = AF_INET;
But this would break all the systems not using sockaddr_in.sin_len, for
example Linux -- so we assume that all these systems provide getaddrinfo()
and use that for now.
---
configure.in | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/configure.in b/configure.in
index 1940834..567f216 100644
--- a/configure.in
+++ b/configure.in
@@ -73,7 +73,6 @@ AC_DEFUN([GCC_STACK_PROTECT_CC],[
fi
])
-
if test "$GCC" = "yes"; then
# We are using the GNU C compiler. Good!
CFLAGS="$CFLAGS -pipe -W -Wall -Wpointer-arith -Wstrict-prototypes"
@@ -125,7 +124,6 @@ AC_TRY_COMPILE([
AC_TYPE_SIGNAL
AC_TYPE_SIZE_T
-
# -- Libraries --
AC_CHECK_LIB(UTIL,memmove)
@@ -141,7 +139,8 @@ AC_CHECK_FUNCS([ \
bind gethostbyaddr gethostbyname gethostname inet_ntoa \
setsid setsockopt socket strcasecmp waitpid],,AC_MSG_ERROR([required function missing!]))
-AC_CHECK_FUNCS(inet_aton isdigit sigaction snprintf vsnprintf strdup strlcpy strlcat strtok_r)
+AC_CHECK_FUNCS(getaddrinfo getnameinfo inet_aton isdigit sigaction snprintf \
+ vsnprintf strdup strlcpy strlcat strtok_r)
# -- Configuration options --
@@ -479,6 +478,8 @@ AC_ARG_ENABLE(ipv6,
if test "$enableval" = "yes"; then x_ipv6_on=yes; fi
)
if test "$x_ipv6_on" = "yes"; then
+ # getaddrinfo() and getnameinfo() are optional when not compiling
+ # with IPv6 support, but are required for IPv6 to work!
AC_CHECK_FUNCS([ \
getaddrinfo getnameinfo \
],,AC_MSG_ERROR([required function missing for IPv6 support!]))
Module: ngircd.git
Branch: master
Commit: e7a33604921ccb389a83e2d900437670f0a5e5d5
URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=e7a33604…
Author: Alexander Barton <alex(a)barton.de>
Date: Mon Sep 14 00:25:48 2009 +0200
Always use get{add|name}info() when available
Both getaddrinfo() and getnameinfo() are now used always when available, and
not only when compiling ngIRCd with support for IPv6.
This not only enables ngIRCd to handle multiple addresses per hostname when
compiled without support for IPv6, but fixes binding ngIRCd to IP addresses
on Mac OS X (and probably other BSD-based systems) as well: these systems
require that sockaddr_in is zeroed out and sockaddr_in.sin_len is set to
sizeof(sockaddr_in) like that:
src/ipaddr/ng_ipaddr.c, line 54:
assert(ip_str);
+ memset(addr, 0, sizeof *addr);
+ addr->sin4.sin_len = sizeof(addr->sin4);
addr->sin4.sin_family = AF_INET;
But this would break all the systems not using sockaddr_in.sin_len, for
example Linux -- so we assume that all these systems provide getaddinfo()
and use that for now.
---
configure.in | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/configure.in b/configure.in
index 1940834..567f216 100644
--- a/configure.in
+++ b/configure.in
@@ -73,7 +73,6 @@ AC_DEFUN([GCC_STACK_PROTECT_CC],[
fi
])
-
if test "$GCC" = "yes"; then
# We are using the GNU C compiler. Good!
CFLAGS="$CFLAGS -pipe -W -Wall -Wpointer-arith -Wstrict-prototypes"
@@ -125,7 +124,6 @@ AC_TRY_COMPILE([
AC_TYPE_SIGNAL
AC_TYPE_SIZE_T
-
# -- Libraries --
AC_CHECK_LIB(UTIL,memmove)
@@ -141,7 +139,8 @@ AC_CHECK_FUNCS([ \
bind gethostbyaddr gethostbyname gethostname inet_ntoa \
setsid setsockopt socket strcasecmp waitpid],,AC_MSG_ERROR([required function missing!]))
-AC_CHECK_FUNCS(inet_aton isdigit sigaction snprintf vsnprintf strdup strlcpy strlcat strtok_r)
+AC_CHECK_FUNCS(getaddrinfo getnameinfo inet_aton isdigit sigaction snprintf \
+ vsnprintf strdup strlcpy strlcat strtok_r)
# -- Configuration options --
@@ -479,6 +478,8 @@ AC_ARG_ENABLE(ipv6,
if test "$enableval" = "yes"; then x_ipv6_on=yes; fi
)
if test "$x_ipv6_on" = "yes"; then
+ # getaddrinfo() and getnameinfo() are optional when not compiling
+ # with IPv6 support, but are required for IPv6 to work!
AC_CHECK_FUNCS([ \
getaddrinfo getnameinfo \
],,AC_MSG_ERROR([required function missing for IPv6 support!]))
Module: ngircd.git
Branch: master
Commit: ed72bf4cebe47dda78a41fbeebe803caa13f2cfa
URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=ed72bf4c…
Author: Florian Westphal <fw(a)strlen.de>
Date: Fri Sep 11 23:09:11 2009 +0200
resolve.c: fix valgrind 'uninitialized memory' warning
fix the following warning generated by valgrind if ipv6 is enabled:
Syscall param write(buf) points to uninitialised byte(s)
at 0x4000982: (within /lib/ld-2.9.so)
by 0x80681A8: Resolve_Name (resolve.c:477)
by 0x805439F: Conn_Handler (conn.c:1658)
by 0x804AA7C: main (ngircd.c:331)
The warning is because ng_ipaddr_t can be a union, and only the
necessary parts are initialised. The callers know what part
of the union is valid, so this is not a bug.
---
src/ngircd/resolve.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/src/ngircd/resolve.c b/src/ngircd/resolve.c
index 20077a4..b1487be 100644
--- a/src/ngircd/resolve.c
+++ b/src/ngircd/resolve.c
@@ -291,6 +291,8 @@ ForwardLookup(const char *hostname, array *IpAddr)
if (!Conf_ConnectIPv4)
hints.ai_family = AF_INET6;
#endif
+ memset(&addr, 0, sizeof(addr));
+
res = getaddrinfo(hostname, NULL, &hints, &ai_results);
switch (res) {
case 0: break;
Module: ngircd.git
Branch: master
Commit: d76910ce7b9fad5679b7c614ed086e036560e37d
URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=d76910ce…
Author: Florian Westphal <fw(a)strlen.de>
Date: Fri Sep 11 22:51:00 2009 +0200
conn.c: fix resolver server address backlog
if more than one ip address is returned for a single host
name, ngircd is supposed to try other addresses in case
connect() to the first address returned fails for some
reason.
Alexander Barton noticed that this did not work at all,
as the additional results were not stored.
---
src/ngircd/conn.c | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/ngircd/conn.c b/src/ngircd/conn.c
index d6ad1e7..cd5921a 100644
--- a/src/ngircd/conn.c
+++ b/src/ngircd/conn.c
@@ -1826,7 +1826,8 @@ cb_Connect_to_Server(int fd, UNUSED short events)
size_t len;
ng_ipaddr_t dest_addrs[4]; /* we can handle at most 3; but we read up to
four so we can log the 'more than we can handle'
- condition */
+ condition. First result is tried immediately, rest
+ is saved for later if needed. */
LogDebug("Resolver: Got forward lookup callback on fd %d, events %d", fd, events);
@@ -1851,13 +1852,13 @@ cb_Connect_to_Server(int fd, UNUSED short events)
LogDebug("Got result from resolver: %u structs (%u bytes).", len/sizeof(ng_ipaddr_t), len);
- memset(&Conf_Server[i].dst_addr, 0, sizeof(&Conf_Server[i].dst_addr));
+ memset(&Conf_Server[i].dst_addr, 0, sizeof(Conf_Server[i].dst_addr));
if (len > sizeof(ng_ipaddr_t)) {
/* more than one address for this hostname, remember them
* in case first address is unreachable/not available */
len -= sizeof(ng_ipaddr_t);
- if (len > sizeof(&Conf_Server[i].dst_addr)) {
- len = sizeof(&Conf_Server[i].dst_addr);
+ if (len > sizeof(Conf_Server[i].dst_addr)) {
+ len = sizeof(Conf_Server[i].dst_addr);
Log(LOG_NOTICE,
"Notice: Resolver returned more IP Addresses for host than we can handle, additional addresses dropped.");
}