]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 450] Windows only: Under original Windows NT we must not discard the
authorMartin Burnicki <burnicki@ntp.org>
Thu, 7 Aug 2008 18:44:31 +0000 (20:44 +0200)
committerMartin Burnicki <burnicki@ntp.org>
Thu, 7 Aug 2008 18:44:31 +0000 (20:44 +0200)
wildcard socket to workaround a bug in NT's getsockname().

bk: 489b428fczZOmvjtp5I1T8xbsa8txg

ChangeLog
ntpd/ntp_peer.c
ports/winnt/ntpd/ntservice.c

index 177b3dff8e672917790ebe47d9c5d3aa65e1fcea..5ddc60ec013fa71f4a0a5dce91f6c8cea47f060f 100644 (file)
--- 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
index 1655d327e2846965011ff866ab02f63980c99915..04f9e8a9db9abdeecd5bb04ffd8006fbee134b1f 100644 (file)
 #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;
 }
index 14a3a83339f2409b2a8e844220cccacdf7de9cf3..a9afe1f681b9f9bf85a646c465ca8762658a1ffc 100644 (file)
@@ -26,6 +26,7 @@
 #include "ntservice.h"
 #include "clockstuff.h"
 #include "ntp_iocompletionport.h"
+#include "isc/win32os.h"
 #ifdef DEBUG
 #include <crtdbg.h>
 #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") ||