From: Dave Hart Date: Mon, 12 Oct 2009 15:24:02 +0000 (+0000) Subject: [Bug 1339] Fix Windows-only ntp_strerror() infinite recursion. X-Git-Tag: NTP_4_2_5P232_RC~3^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5ea9f458ccf2696740bd8aa8e374dbd0208e5c7f;p=thirdparty%2Fntp.git [Bug 1339] Fix Windows-only ntp_strerror() infinite recursion. bk: 4ad34a12J6T80GTcL_CL-TnwX4r5XA --- diff --git a/ChangeLog b/ChangeLog index f86a5be54..ff79a630d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,4 @@ +* [Bug 1339] Fix Windows-only ntp_strerror() infinite recursion. (4.2.5p231-RC) 2009/10/10 Released by Harlan Stenn * [Bug 1335] Broadcast client degraded by wildcard default change. (4.2.5p230-RC) 2009/10/09 Released by Harlan Stenn diff --git a/lib/isc/win32/strerror.c b/lib/isc/win32/strerror.c index b76c8191f..dec60f047 100644 --- a/lib/isc/win32/strerror.c +++ b/lib/isc/win32/strerror.c @@ -42,9 +42,12 @@ GetWSAErrorMessage(int errval); char * NTstrerror(int err, BOOL *bfreebuf); -#ifndef CRT_strerror -#define CRT_strerror(e) strerror(e) -#endif +/* + * ntp ports/winnt/include/config.h #defines strerror() to + * ntp_strerror() to handle OS errors as well as CRT. We need the + * CRT strerror() here so #undef. + */ +#undef strerror /* * We need to do this this way for profiled locks. @@ -126,7 +129,7 @@ NTstrerror(int errval, BOOL *bfreebuf) { return (retmsg); } - retmsg = CRT_strerror(errval); + retmsg = strerror(errval); /* * If it's not one of the standard Unix error codes, diff --git a/ports/winnt/include/config.h b/ports/winnt/include/config.h index 6e7d2a33a..ec4733f95 100644 --- a/ports/winnt/include/config.h +++ b/ports/winnt/include/config.h @@ -291,10 +291,7 @@ typedef __int32 int32_t; /* define a typedef for int32_t */ #define STDERR_FILENO _fileno(stderr) /* Point to a local version for error string handling */ -#define CRT_strerror(e) strerror(e) #define strerror(e) ntp_strerror(e) -extern char * ntp_strerror(int); - # define MCAST /* Enable Multicast Support */ # define MULTICAST_NONEWSOCKET /* Don't create a new socket for mcast address */ diff --git a/ports/winnt/include/syslog.h b/ports/winnt/include/syslog.h index 5cbf30a00..e4fe166e0 100644 --- a/ports/winnt/include/syslog.h +++ b/ports/winnt/include/syslog.h @@ -79,4 +79,7 @@ InitNTLogging(FILE *, int); void NTReportError(const char *, const char *); +char * +ntp_strerror(int); + #endif diff --git a/ports/winnt/libntp/syslog.c b/ports/winnt/libntp/syslog.c index 27513f353..c45bb3d01 100644 --- a/ports/winnt/libntp/syslog.c +++ b/ports/winnt/libntp/syslog.c @@ -25,6 +25,8 @@ #include #include +#include + #include "messages.h" static HANDLE hAppLog = NULL; @@ -197,10 +199,9 @@ NTReportError(const char *name, const char *str) { /* * ntp_strerror() - provide strerror()-compatible wrapper for libisc's - * NTstrerror(), which knows about Windows as well as + * isc__strerror(), which knows about Windows as well as * C runtime error messages. */ -extern char *NTstrerror(int err, BOOL *bfreebuf); char * ntp_strerror( @@ -208,15 +209,8 @@ ntp_strerror( ) { static char msgbuf[128]; - char * pmsg; - BOOL freep; - - pmsg = NTstrerror(code, &freep); - strncpy(msgbuf, pmsg, sizeof(msgbuf)); - msgbuf[sizeof(msgbuf) - 1] = '\0'; - if (freep) - LocalFree(pmsg); + isc__strerror(code, msgbuf, sizeof(msgbuf)); return msgbuf; }