]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 1339] Fix Windows-only ntp_strerror() infinite recursion.
authorDave Hart <hart@ntp.org>
Mon, 12 Oct 2009 15:24:02 +0000 (15:24 +0000)
committerDave Hart <hart@ntp.org>
Mon, 12 Oct 2009 15:24:02 +0000 (15:24 +0000)
bk: 4ad34a12J6T80GTcL_CL-TnwX4r5XA

ChangeLog
lib/isc/win32/strerror.c
ports/winnt/include/config.h
ports/winnt/include/syslog.h
ports/winnt/libntp/syslog.c

index f86a5be54bb2b40e1c8ba9fd3ac529a378df0b51..ff79a630d16f46c690b846a955619957958426e3 100644 (file)
--- 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 <stenn@ntp.org>
 * [Bug 1335] Broadcast client degraded by wildcard default change.
 (4.2.5p230-RC) 2009/10/09 Released by Harlan Stenn <stenn@ntp.org>
index b76c8191f4c7f4fc24e32b0e73f76d71bab3b0df..dec60f04729b89c1a9df6214b9614accfba5fff0 100644 (file)
@@ -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,
index 6e7d2a33ae40df9ae36ac10feb649164df28a274..ec4733f95c397149a95d4d829dc9928999c7136a 100644 (file)
@@ -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 */
index 5cbf30a00a13acafb503d5a37d966d35e033963b..e4fe166e0994b619d111bf58e3ea483317c493b6 100644 (file)
@@ -79,4 +79,7 @@ InitNTLogging(FILE *, int);
 void
 NTReportError(const char *, const char *);
 
+char *
+ntp_strerror(int);
+
 #endif
index 27513f3534751015b3d969a4560eebf09d2bbcd9..c45bb3d01d8f435a4827e384bda404d3a4853c5b 100644 (file)
@@ -25,6 +25,8 @@
 #include <stdlib.h>
 #include <syslog.h>
 
+#include <isc/strerror.h>
+
 #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;
 }