From: Dave Hart Date: Sat, 8 Jan 2011 10:54:12 +0000 (+0000) Subject: [Bug 1780] Windows ntpd 4.2.7p114 crashes in ioctl(). X-Git-Tag: NTP_4_2_7P115~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f07ef91c343dfca1db9168718019ff459952803c;p=thirdparty%2Fntp.git [Bug 1780] Windows ntpd 4.2.7p114 crashes in ioctl(). bk: 4d284254F9zO1X2o2ToWkvUvtLxQjQ --- diff --git a/ChangeLog b/ChangeLog index caba3c0c3..1a07c319b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,4 @@ +* [Bug 1780] Windows ntpd 4.2.7p114 crashes in ioctl(). (4.2.7p114) 2011/01/08 Released by Harlan Stenn * Fix for openssl pkg-config detection eval failure. * Add erealloc_zero(), refactor estrdup(), emalloc(), emalloc_zero() to diff --git a/libntp/socket.c b/libntp/socket.c index 32417feee..d117c83c1 100644 --- a/libntp/socket.c +++ b/libntp/socket.c @@ -16,6 +16,14 @@ #include +/* + * Windows C runtime ioctl() can't deal properly with sockets, + * map to ioctlsocket for this source file. + */ +#ifdef SYS_WINNT +#define ioctl(fd, opt, val) ioctlsocket(fd, opt, (u_long *)(val)) +#endif + /* HMS: Is this the best place to put the qos global? */ #if defined(HAVE_IPTOS_SUPPORT) diff --git a/ntpd/ntp_io.c b/ntpd/ntp_io.c index 3e63a2655..20a803cbf 100644 --- a/ntpd/ntp_io.c +++ b/ntpd/ntp_io.c @@ -102,12 +102,7 @@ nic_rule *nic_rule_list; #if defined(SYS_WINNT) #include "win32_io.h" #include -/* - * Windows C runtime ioctl() can't deal properly with sockets, - * map to ioctlsocket for this source file. - */ -#define ioctl(fd, opt, val) ioctlsocket((fd), (opt), (u_long *)(val)) -#endif /* SYS_WINNT */ +#endif /* * We do asynchronous input using the SIGIO facility. A number of @@ -2892,69 +2887,6 @@ io_multicast_del( } -#if 0 -/* MOVED to libntp/socket.c, to become part of libntp. */ -/* - * init_nonblocking_io() - set up descriptor to be non blocking - */ -static void init_nonblocking_io( - SOCKET fd - ) -{ - /* - * set non-blocking, - */ - -#ifdef USE_FIONBIO - /* in vxWorks we use FIONBIO, but the others are defined for old systems, so - * all hell breaks loose if we leave them defined - */ -#undef O_NONBLOCK -#undef FNDELAY -#undef O_NDELAY -#endif - -#if defined(O_NONBLOCK) /* POSIX */ - if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0) { - msyslog(LOG_ERR, - "fcntl(O_NONBLOCK) fails on fd #%d: %m", fd); - exit(1); - } -#elif defined(FNDELAY) - if (fcntl(fd, F_SETFL, FNDELAY) < 0) { - msyslog(LOG_ERR, "fcntl(FNDELAY) fails on fd #%d: %m", - fd); - exit(1); - } -#elif defined(O_NDELAY) /* generally the same as FNDELAY */ - if (fcntl(fd, F_SETFL, O_NDELAY) < 0) { - msyslog(LOG_ERR, "fcntl(O_NDELAY) fails on fd #%d: %m", - fd); - exit(1); - } -#elif defined(FIONBIO) - { - int on = 1; - - if (ioctl(fd, FIONBIO, &on) < 0) { - msyslog(LOG_ERR, - "ioctl(FIONBIO) fails on fd #%d: %m", - fd); - exit(1); - } - } -#elif defined(FIOSNBIO) - if (ioctl(fd, FIOSNBIO, &on) < 0) { - msyslog(LOG_ERR, - "ioctl(FIOSNBIO) fails on fd #%d: %m", fd); - exit(1); - } -#else -# include "Bletch: Need non-blocking I/O!" -#endif -} -#endif /* 0 */ - /* * open_socket - open a socket, returning the file descriptor */