From: Martin Burnicki Date: Thu, 7 Aug 2008 18:44:31 +0000 (+0200) Subject: [Bug 450] Windows only: Under original Windows NT we must not discard the X-Git-Tag: NTP_4_2_4P5_RC2~2^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f8eef535ad7d38cb5525a0ca270776d935f45dbc;p=thirdparty%2Fntp.git [Bug 450] Windows only: Under original Windows NT we must not discard the wildcard socket to workaround a bug in NT's getsockname(). bk: 489b428fczZOmvjtp5I1T8xbsa8txg --- diff --git a/ChangeLog b/ChangeLog index 177b3dff8..5ddc60ec0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,5 @@ +* [Bug 450] Windows only: Under original Windows NT we must not discard the + wildcard socket to workaround a bug in NT's getsockname(). * [Bug 959] Refclock on Windows not properly releasing recvbuffs. * [Bug 993] Fix memory leak when fetching system messages. * [Bug 987] Wake up the resolver thread/process when a new interface has diff --git a/ntpd/ntp_peer.c b/ntpd/ntp_peer.c index 1655d327e..04f9e8a9d 100644 --- a/ntpd/ntp_peer.c +++ b/ntpd/ntp_peer.c @@ -15,6 +15,10 @@ #include "openssl/rand.h" #endif /* OPENSSL */ +#ifdef SYS_WINNT +extern int accept_wildcard_if_for_winnt; +#endif + /* * Table of valid association combinations * --------------------------------------- @@ -27,7 +31,7 @@ * PASSIVE | e 1 e 0 0 0 * CLIENT | e 0 0 0 1 1 * SERVER | e 0 0 0 0 0 - * BCAST | e 0 0 0 0 0 + * BCAST | e 0 0 0 0 0 * BCLIENT | e 0 0 0 e 1 * * One point to note here: a packet in BCAST mode can potentially match @@ -706,7 +710,11 @@ select_peerinterface(struct peer *peer, struct sockaddr_storage *srcadr, struct * crypto will not work without knowing the own transmit address */ if (interface != NULL && interface->flags & INT_WILDCARD) - interface = NULL; +#ifdef SYS_WINNT + if ( !accept_wildcard_if_for_winnt ) +#endif + interface = NULL; + return interface; } diff --git a/ports/winnt/ntpd/ntservice.c b/ports/winnt/ntpd/ntservice.c index 14a3a8333..a9afe1f68 100644 --- a/ports/winnt/ntpd/ntservice.c +++ b/ports/winnt/ntpd/ntservice.c @@ -26,6 +26,7 @@ #include "ntservice.h" #include "clockstuff.h" #include "ntp_iocompletionport.h" +#include "isc/win32os.h" #ifdef DEBUG #include #endif @@ -37,6 +38,7 @@ static char ConsoleTitle[128]; static int glb_argc; static char **glb_argv; HANDLE hServDoneEvent = NULL; +int accept_wildcard_if_for_winnt; extern volatile int debug; extern char *progname; @@ -78,7 +80,12 @@ int main( int argc, char *argv[] ) glb_argc = argc; glb_argv = argv; - /* Command line users should put -f in the options */ + /* Under original Windows NT we must not discard the wildcard */ + /* socket to workaround a bug in NT's getsockname(). */ + if ( isc_win32os_majorversion() <= 4 ) + accept_wildcard_if_for_winnt = 1; + + /* Command line users should put -n in the options */ while (argv[i]) { if (!_strnicmp(argv[i], "-d", 2) || !strcmp(argv[i], "-q") ||