Suppress OpenSSL 3 deprecation warning clutter.
Fix problem with statisics files not being generated (broken after 4.2.8p17)
Remove unneeded 200ms wait during NT service shutdown.
Do not compile unneded bsd_strerror.c on Windows.
Reduce HAVE_IO_COMPLETION_PORT #ifdef clutter by moving calls
to io_completion_port_remove_socket into
close_and_delete_fd_from_list().
Silence warnings building on macOS about incompatible types
for timeval.tv_usec.
Move massive config parser debug output from debug level 5 to 9.
Move yylex() debug output from level 4 to level 10.
Change overallocated 1k static lexeme buffer to 128 bytes.
bk: 65b44cdd3_DyQ6f9O7DUnyWr057aPQ
---
+* [Bug 3903] lib/isc/win32/strerror.c NTstrerror() is not thread-safe.
+ <hart@ntp.org>
* [Bug 3901] LIB_GETBUF isn't thread-safe. <hart@ntp.org>
* [Bug 3900] fast_xmit() selects wrong local addr responding to mcast on
Windows. <hart@ntp.org>
* Quiet local addr change logging when unpeering. <hart@ntp.org>
* Correct missing arg for %s printf specifier in
send_blocking_resp_internal(). <hart@ntp.org>
+* Suppress OpenSSL 3 deprecation warning clutter. <hart@ntp.org>
---
(4.2.8p17) 2023/06/06 Released by Harlan Stenn <stenn@ntp.org>
# define UNBLOCK_IO_AND_ALARM() do {} while (0)
# define BLOCK_IO_AND_ALARM() do {} while (0)
#endif
-#define latoa(pif) localaddrtoa(pif)
+#define eptoa(pif) localaddrtoa(pif)
+#define latoa(pif) eptoa(pif)
extern const char * localaddrtoa(endpt *);
#ifdef DEBUG
extern const char * iflags_str(u_int32 iflags);
#include <isc/strerror.h>
#include <isc/util.h>
+#include "lib_strbuf.h"
+
/*
* Forward declarations
*/
*pch = '\0';
}
- /* strip any trailing CR/LF */
+ /* strip any trailing CR/LF and spaces */
if (lpMsgBuf != NULL) {
last = strlen(lpMsgBuf);
if (last > 0) {
--last;
}
while ('\n' == lpMsgBuf[last] ||
- '\r' == lpMsgBuf[last]) {
+ '\r' == lpMsgBuf[last] ||
+ ' ' == lpMsgBuf[last]) {
lpMsgBuf[last] = '\0';
if (last > 0) {
NTstrerror(int err, BOOL *bfreebuf) {
char *retmsg = NULL;
- /* Copy the error value first in case of other errors */
- DWORD errval = err;
-
*bfreebuf = FALSE;
/* Get the Winsock2 error messages */
- if (errval >= WSABASEERR && errval <= (WSABASEERR + 1999)) {
- retmsg = GetWSAErrorMessage(errval);
- if (retmsg != NULL)
- return (retmsg);
+ /* DLH this may not be needed, FormatError/FormatMessage may handle Winsock error codes */
+ if (err >= WSABASEERR && err <= (WSABASEERR + 1999)) {
+ retmsg = GetWSAErrorMessage(err);
}
/*
* If it's not one of the standard Unix error codes,
* try a system error message
*/
- if (errval > (DWORD) _sys_nerr) {
- *bfreebuf = TRUE;
- return (FormatError(errval));
- } else {
- return (strerror(errval));
+ if (NULL == retmsg) {
+ if (err > _sys_nerr) {
+ *bfreebuf = TRUE;
+ retmsg = FormatError(err);
+ } else {
+ retmsg = lib_getbuf();
+ if (0 != strerror_s(retmsg, LIB_BUFLENGTH, err)) {
+ snprintf(retmsg, LIB_BUFLENGTH,
+ "Unknown error number %d/0x%x",
+ err, err);
+ }
+ }
}
+ return retmsg;
}
/*
{
# ifdef WORK_PIPE
if (1 != write(c->resp_write_pipe, "", 1))
- msyslog(LOG_WARNING, "async resolver: blocking_get%sinfo",
+ msyslog(LOG_WARNING, "async resolver: blocking_get%sinfo"
" failed to notify main thread!",
(BLOCKING_GETNAMEINFO == resp->rtype)
? "name"
/* Set the statistics directory */
if (ptree->stats_dir) {
- stats_config(STATS_STATSDIR, ptree->stats_dir, 0);
+ stats_config(STATS_STATSDIR, ptree->stats_dir, TRUE);
}
/* NOTE:
if_name = estrdup(if_name);
switch (curr_node->match_class) {
-#ifdef DEBUG
default:
+#ifdef DEBUG
fatal_error("config_nic_rules: match-class-token=%d", curr_node->match_class);
#endif
+ case T_All:
+ match_type = MATCH_ALL;
+ break;
case 0:
/*
}
break;
- case T_All:
- match_type = MATCH_ALL;
- break;
-
case T_Ipv4:
match_type = MATCH_IPV4;
break;
}
switch (curr_node->action) {
-#ifdef DEBUG
default:
+#ifdef DEBUG
fatal_error("config_nic_rules: action-token=%d", curr_node->action);
#endif
case T_Listen:
}
cfgt.source.value.s = estrdup(alt_config_file);
#endif /* SYS_WINNT */
- } else
+ } else {
cfgt.source.value.s = estrdup(config_file);
-
+ }
/*** BULK OF THE PARSER ***/
#ifdef DEBUG
- yydebug = !!(debug >= 5);
+ yydebug = (debug >= 9);
#endif
yyparse();
lex_drop_stack();
static endpt * find_flagged_addr_in_list(sockaddr_u *, u_int32);
static void delete_addr_from_list (sockaddr_u *);
static void delete_interface_from_list(endpt *);
-static void close_and_delete_fd_from_list(SOCKET);
+static void close_and_delete_fd_from_list(SOCKET, endpt *);
static void add_addr_to_list (sockaddr_u *, endpt *);
static void create_wildcards (u_short);
static endpt * findlocalinterface (sockaddr_u *, int, int);
}
/*
- * remove asynchio_reader
+ * remove asyncio_reader
*/
static void
remove_asyncio_reader(
UNLINK_SLIST(unlinked, asyncio_reader_list, reader, link,
struct asyncio_reader);
- if (reader->fd != INVALID_SOCKET)
- close_and_delete_fd_from_list(reader->fd);
-
+ if (reader->fd != INVALID_SOCKET) {
+ close_and_delete_fd_from_list(reader->fd, NULL);
+ }
reader->fd = INVALID_SOCKET;
}
#endif /* !defined(HAVE_IO_COMPLETION_PORT) && defined(HAS_ROUTING_SOCKET) */
ep->sent,
ep->notsent,
current_time - ep->starttime);
-# ifdef HAVE_IO_COMPLETION_PORT
- io_completion_port_remove_socket(ep->fd, ep);
-# endif
- close_and_delete_fd_from_list(ep->fd);
+ close_and_delete_fd_from_list(ep->fd, ep);
ep->fd = INVALID_SOCKET;
}
msyslog(LOG_INFO,
"stop listening for broadcasts to %s on interface #%d %s",
stoa(&ep->bcast), ep->ifnum, ep->name);
-# ifdef HAVE_IO_COMPLETION_PORT
- io_completion_port_remove_socket(ep->bfd, ep);
-# endif
- close_and_delete_fd_from_list(ep->bfd);
+ close_and_delete_fd_from_list(ep->bfd, ep);
ep->bfd = INVALID_SOCKET;
}
# ifdef HAVE_IO_COMPLETION_PORT
msyslog(LOG_INFO,
"stop listening for broadcasts to %s on interface #%d %s",
stoa(&ep->bcast), ep->ifnum, ep->name);
-# ifdef HAVE_IO_COMPLETION_PORT
- io_completion_port_remove_socket(ep->bfd, ep);
-# endif
- close_and_delete_fd_from_list(ep->bfd);
+ close_and_delete_fd_from_list(ep->bfd, ep);
ep->bfd = INVALID_SOCKET;
}
ep->flags &= ~INT_BCASTOPEN;
const sockaddr_u * a2
)
{
- u_char *pdist;
- u_char *p1;
- u_char *p2;
- size_t cb;
- int different;
- int a1_greater;
- u_int u;
+ u_char * pdist;
+ const u_char * p1;
+ const u_char * p2;
+ size_t cb;
+ int different;
+ int a1_greater;
+ u_int u;
REQUIRE(AF(a1) == AF(a2));
AF(dist) = AF(a1);
if (IS_IPV4(a1)) {
- pdist = (u_char *)&NSRCADR(dist);
- p1 = (u_char *)&NSRCADR(a1);
- p2 = (u_char *)&NSRCADR(a2);
+ pdist = ( u_char *)&NSRCADR(dist);
+ p1 = (const u_char *)&NSRCADR(a1);
+ p2 = (const u_char *)&NSRCADR(a2);
} else {
- pdist = (u_char *)&NSRCADR(dist);
- p1 = (u_char *)&NSRCADR(a1);
- p2 = (u_char *)&NSRCADR(a2);
+ pdist = ( u_char *)&NSRCADR(dist);
+ p1 = (const u_char *)&NSRCADR(a1);
+ p2 = (const u_char *)&NSRCADR(a2);
}
cb = SIZEOF_INADDR(AF(dist));
different = FALSE;
# ifdef HAVE_IO_COMPLETION_PORT
io_completion_port_remove_clock_io(rio);
# endif
- close_and_delete_fd_from_list(rio->fd);
+ close_and_delete_fd_from_list(rio->fd, NULL);
purge_recv_buffers_for_fd(rio->fd);
rio->fd = -1;
}
maxactivefd = 0;
while (fd_list != NULL)
- close_and_delete_fd_from_list(fd_list->fd);
+ close_and_delete_fd_from_list(fd_list->fd, NULL);
UNBLOCKIO();
}
static void
close_and_delete_fd_from_list(
- SOCKET fd
+ SOCKET fd,
+ endpt *ep /* req. if fd is in struct endpt */
)
{
vsock_t *lsock;
switch (lsock->type) {
case FD_TYPE_SOCKET:
+ #ifdef HAVE_IO_COMPLETION_PORT
+ if (ep != NULL) {
+ io_completion_port_remove_socket(fd, ep);
+ }
+ #endif
closesocket(lsock->fd);
break;
if (p->dstadr == dstadr)
return;
+ /*
+ * Do not change the local address of a link-local
+ * peer address.
+ */
+ if ( p->dstadr != NULL && is_linklocal(&p->dstadr->sin)
+ && dstadr != NULL) {
+ return;
+ }
+
+ /*
+ * Do not set the local address for a link-local IPv6 peer
+ * to one with a different scope ID.
+ */
+ if ( dstadr != NULL && IS_IPV6(&p->srcadr)
+ && SCOPE(&dstadr->sin) != SCOPE(&p->srcadr)) {
+ return;
+ }
+
/*
* Don't accept updates to a separate multicast receive-only
* endpt while a BCLNT peer is running its unicast protocol.
p->dstadr->peercnt--;
UNLINK_SLIST(unlinked, p->dstadr->peers, p, ilink,
struct peer);
- if (!IS_MCAST(&p->srcadr) &&!(FLAG_DISABLED & p->flags)) {
- msyslog(LOG_INFO, "%s local addr %s -> %s",
- stoa(&p->srcadr), latoa(p->dstadr),
- latoa(dstadr));
- }
+ }
+ if ( !IS_MCAST(&p->srcadr) && !(FLAG_DISABLED & p->flags)
+ && !initializing) {
+ msyslog(LOG_INFO, "%s local addr %s -> %s",
+ stoa(&p->srcadr), eptoa(p->dstadr),
+ eptoa(dstadr));
}
p->dstadr = dstadr;
if (p->dstadr != NULL && (p->reach & 0x3)) {
continue;
}
- /*
- * Do not change the local address of a link-local
- * peer address.
- */
- if (p->dstadr != NULL && is_linklocal(&p->srcadr)) {
- continue;
- }
peer_refresh_interface(p);
}
}
set_peerdstadr(peer,
select_peerinterface(peer, srcadr, dstadr));
+ /*
+ * Zero for minpoll or maxpoll means use defaults.
+ */
+ peer->maxpoll = (0 == maxpoll)
+ ? NTP_MAXDPOLL
+ : maxpoll;
+ peer->minpoll = (0 == minpoll)
+ ? NTP_MINDPOLL
+ : minpoll;
+
/*
* Clamp maxpoll and minpoll within NTP_MINPOLL and NTP_MAXPOLL,
* and further clamp minpoll less than or equal maxpoll.
*/
- peer->maxpoll = CLAMP(maxpoll, NTP_MINPOLL, NTP_MAXPOLL);
- peer->minpoll = CLAMP(minpoll, NTP_MINPOLL, peer->maxpoll);
+ peer->maxpoll = CLAMP(peer->maxpoll, NTP_MINPOLL, NTP_MAXPOLL);
+ peer->minpoll = CLAMP(peer->minpoll, NTP_MINPOLL, peer->maxpoll);
if (peer->dstadr != NULL) {
DPRINTF(3, ("newpeer(%s): using fd %d and our addr %s\n",
* ------------------------
*/
-#define MAX_LEXEME (1024 + 1) /* The maximum size of a lexeme */
+#define MAX_LEXEME 128 /* The maximum size of a lexeme */
char yytext[MAX_LEXEME]; /* Buffer for storing the input text/lexeme */
u_int32 conf_file_sum; /* Simple sum of characters read */
*/
static struct FILE_INFO *
-_drop_stack_do(
+drop_stack_do(
struct FILE_INFO * head
)
{
void
lex_drop_stack()
{
- lex_stack = _drop_stack_do(lex_stack);
+ lex_stack = drop_stack_do(lex_stack);
}
/* Flush the lexer input stack: This will nip all input objects on the
if (NULL != lex_stack) {
retv = !lex_stack->force_eof;
lex_stack->force_eof = TRUE;
- lex_stack->st_next = _drop_stack_do(
+ lex_stack->st_next = drop_stack_do(
lex_stack->st_next);
}
return retv;
normal_return:
if (T_EOC == token)
- DPRINTF(4,("\t<end of command>\n"));
+ DPRINTF(10, ("\t<end of command>\n"));
else
- DPRINTF(4, ("yylex: lexeme '%s' -> %s\n", yytext,
+ DPRINTF(10, ("yylex: lexeme '%s' -> %s\n", yytext,
token_name(token)));
if (!yylval_was_set)
return token;
lex_too_long:
+ /*
+ * DLH: What is the purpose of the limit of 50?
+ * Is there any reason for yytext[] to be bigger?
+ */
yytext[min(sizeof(yytext) - 1, 50)] = 0;
msyslog(LOG_ERR,
"configuration item on line %d longer than limit of %lu, began with '%s'",
l_fp DCDSTime; /* PPS-hack: time of DCD ON */
l_fp FlagTime; /* time stamp of flag/event char*/
l_fp RecvTime; /* time stamp of callback */
- DWORD com_events; /* buffer for COM events */
+ DWORD com_events; /* bitmask of serial events */
u_int flTsDCDS : 1; /* DCDSTime valid? */
u_int flTsFlag : 1; /* FlagTime valid? */
} aux;
void
ntservice_exit(void)
{
- uninit_io_completion_port();
peer_cleanup();
- Sleep( 200 ); //##++
-
+ uninit_io_completion_port();
reset_winnt_time();
msyslog(LOG_INFO, "ntservice: The Network Time Protocol Service is stopping.");
<ClCompile Include="..\..\..\..\libntp\authreadkeys.c" />
<ClCompile Include="..\..\..\..\libntp\authusekey.c" />
<ClCompile Include="..\..\..\..\libntp\a_md5encrypt.c" />
- <ClCompile Include="..\..\..\..\libntp\bsd_strerror.c" />
<ClCompile Include="..\..\..\..\libntp\buftvtots.c" />
<ClCompile Include="..\..\..\..\libntp\caljulian.c" />
<ClCompile Include="..\..\..\..\libntp\caltontp.c" />
<ClCompile Include="..\..\..\..\libntp\lib\isc\win32\win32os.c">
<Filter>libisc Source Files</Filter>
</ClCompile>
- <ClCompile Include="..\..\..\..\libntp\bsd_strerror.c">
- <Filter>Source Files</Filter>
- </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\..\sntp\libopts\ag-char-map.h">
for i in $ntp_ssl_incdir_search
do
AC_MSG_NOTICE([Searching for openssl/evp.h in $i])
- CPPFLAGS="$NTPSSL_SAVED_CPPFLAGS $i"
+ CPPFLAGS="$NTPSSL_SAVED_CPPFLAGS -I$i"
dnl force uncached AC_CHECK_HEADER
AS_UNSET([ac_cv_header_openssl_evp_h])
AC_CHECK_HEADER(
VER_SUFFIX=o
AC_CHECK_HEADERS([openssl/cmac.h openssl/hmac.h])
AC_DEFINE([OPENSSL], [], [Use OpenSSL?])
+ dnl OpenSSL 3 deprecates a bunch of functions used by Autokey.
+ dnl Adapting our code to the bold new way is not a priority
+ dnl for us because we do not want to require OpenSSL 3 yet.
+ dnl The deprecation warnings clutter up the build output
+ dnl encouraging the habit of ignoring warninis.
+ dnl So, tell it to the hand, OpenSSL deprecation warnings...
+ AC_DEFINE([OPENSSL_SUPPRESS_DEPRECATED], [1],
+ [Suppress OpenSSL 3 deprecation warnings])
dnl We don't want -Werror for the EVP_MD_do_all_sorted check
CFLAGS="$NTPSSL_SAVED_CFLAGS"
AC_CHECK_FUNCS([EVP_MD_do_all_sorted])
#include <timevalops.h>
#include "unity.h"
-//#include "bug-2803.h"
/* microseconds per second */
#define MICROSECONDS 1000000
if ( failed || verbose )
printf( "timetv %lli|%07li, tvlast %lli|%07li: tvdiff_old: %lli|%07li -> %i, tvdiff_new: %lli|%07li -> %i, same cond: %s\n",
- (long long) timetv.tv_sec, timetv.tv_usec,
- (long long) tvlast.tv_sec, tvlast.tv_usec,
- (long long) tvdiff_old.tv_sec, tvdiff_old.tv_usec, cond_old,
- (long long) tvdiff_new.tv_sec, tvdiff_new.tv_usec, cond_new,
+ (long long) timetv.tv_sec, (u_long)timetv.tv_usec,
+ (long long) tvlast.tv_sec, (u_long)tvlast.tv_usec,
+ (long long) tvdiff_old.tv_sec, (u_long)tvdiff_old.tv_usec, cond_old,
+ (long long) tvdiff_new.tv_sec, (u_long)tvdiff_new.tv_usec, cond_new,
failed ? "NO <<" : "yes" );
return failed ? -1 : 0;
printf("m_expr which is %lld.%06lu \nand\n"
"n_expr which is %lld.%06lu\nare not close; diff=%lld.%06luusec\n",
- (long long)m.tv_sec, m.tv_usec,
- (long long)n.tv_sec, n.tv_usec,
- (long long)diff.tv_sec, diff.tv_usec);
+ (long long)m.tv_sec, (u_long)m.tv_usec,
+ (long long)n.tv_sec, (u_long)n.tv_usec,
+ (long long)diff.tv_sec, (u_long)diff.tv_usec);
return FALSE;
}