From: Dave Hart
Date: Thu, 23 Feb 2023 09:55:50 +0000 (-0500)
Subject: Bugs 3774 and 3793
X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=632a0009e83e70489ea6c549c10e1a367e9f9aa4;p=thirdparty%2Fntp.git
Bugs 3774 and 3793
[Bug 3595] pollskewlist documentation uses | when it shouldn't.
[Bug 3797] Windows getaddrinfo w/AI_ADDRCONFIG fails for localhost when disconnected
[Bug 3774] mode 6 packets corrupted in rawstats file
[Bug 3793] Wrong variable type passed to record_raw_stats().
Remove inappropriate copyright notice in Windows messages.mc and messages.h
bk: 63f73826bn3P4-gBfVNIZJhrfdFOJQ
---
diff --git a/ChangeLog b/ChangeLog
index 6fef4f581..5d076c62c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
-
---
+* [Bug 3595] pollskewlist documentation uses | when it shouldn't.
+ - ntp.conf manual page and miscopt.html corrections.
+* [Bug 3797] Windows getaddrinfo w/AI_ADDRCONFIG fails for localhost when
+ disconnected, breaking ntpq and ntpdc.
+* [Bug 3774] mode 6 packets corrupted in rawstats file
+ - Reported by Edward McGuire, fix identified by .
+* [Bug 3793] Wrong variable type passed to record_raw_stats().
+ - Report and patch by Yuezhen LUAN .
* [Bug 3640] document "discard monitor" and fix the code.
- fixed bug identified by Edward McGuire
* [Bug 3660] Revert 4.2.8p15 change to manycast.
diff --git a/html/copyright.html b/html/copyright.html
index e28b976aa..86c56dc9a 100644
--- a/html/copyright.html
+++ b/html/copyright.html
@@ -9,7 +9,7 @@
Copyright Notice
"Clone me," says Dolly sheepishly.
Last update:
- 4-Feb-2020 23:47
+ 22-Feb-2023 22:35
UTC
@@ -38,7 +38,7 @@
***********************************************************************
* *
-* Copyright (c) Network Time Foundation 2011-2020 *
+* Copyright (c) Network Time Foundation 2011-2023 *
* *
* All Rights Reserved *
* *
diff --git a/html/miscopt.html b/html/miscopt.html
index f5bce4b44..ecbe25fc4 100644
--- a/html/miscopt.html
+++ b/html/miscopt.html
@@ -110,9 +110,7 @@
For the JJY driver (type 40 mode 100 - 180), the argument is one telephone number used to dial the telephone JJY service.
The Hayes command ATDT is normally prepended to the number, which can contain other modem control codes as well.
pollskewlist [poll value
- | value] ... [default value
- | value]
+ >pollskewlist [poll early late] ... [default early late]
Enable skewing of our poll requests to our servers.
poll
is a number between 3 and 17 inclusive, identifying a specific poll interval.
@@ -123,9 +121,8 @@ a poll interval of 17 corresponds to
131,072 seconds, or about a day and a half.
The next two numbers must be between 0 and one-half of the poll interval,
inclusive.
-The first number specifies how early the poll may start,
-while
-the second number specifies how late the poll may be delayed.
+early specifies how early the poll may start, while
+late specifies how late the poll may be delayed.
With no arguments, internally specified default values are chosen.
reset [allpeers] [auth] [ctl] [io] [mem] [sys] [timer]
Reset one or more groups of counters maintained by ntpd and exposed by ntpq and ntpdc.
diff --git a/include/vint64ops.h b/include/vint64ops.h
index 2c3deffb3..7c245b963 100644
--- a/include/vint64ops.h
+++ b/include/vint64ops.h
@@ -23,6 +23,6 @@ extern vint64 subv64i32(const vint64 * lhs, int32_t rhs);
extern vint64 subv64u32(const vint64 * lhs, uint32_t rhs);
/* parsing. works like strtoul() or strtoull() */
-extern vint64 strtouv64(const char * begp, char ** endp, int base);
+extern vint64 strtouv64(const char * begp, const char ** endp, int base);
#endif /*!defined(VINT64OPS_H)*/
diff --git a/libntp/socktoa.c b/libntp/socktoa.c
index 98abe7c42..4071b0a45 100644
--- a/libntp/socktoa.c
+++ b/libntp/socktoa.c
@@ -119,7 +119,7 @@ sock_hash(
/*
* We can't just hash the whole thing because there are hidden
* fields in sockaddr_in6 that might be filled in by recvfrom(),
- * so just use the family, port and address.
+ * so just use the family and address.
*/
pch = (const void *)&AF(addr);
hashVal = 37 * hashVal + *pch;
diff --git a/libntp/vint64ops.c b/libntp/vint64ops.c
index 5adbebbb5..f4fc47fe7 100644
--- a/libntp/vint64ops.c
+++ b/libntp/vint64ops.c
@@ -17,32 +17,13 @@
#include "ntp_fp.h"
#include "vint64ops.h"
-/* ---------------------------------------------------------------------
- * GCC is rather sticky with its 'const' attribute. We have to do it more
- * explicit than with a cast if we want to get rid of a CONST qualifier.
- * Greetings from the PASCAL world, where casting was only possible via
- * untagged unions...
- */
-static inline void*
-noconst(
- const void* ptr
- )
-{
- union {
- const void * cp;
- void * vp;
- } tmp;
- tmp.cp = ptr;
- return tmp.vp;
-}
-
/* -------------------------------------------------------------------------*/
vint64
strtouv64(
- const char * begp,
- char ** endp,
- int base
+ const char *begp,
+ const char **endp,
+ int base
)
{
vint64 res;
@@ -116,7 +97,7 @@ strtouv64(
if (!num)
errno = EINVAL;
if (endp)
- *endp = (char*)noconst(src);
+ *endp = (const char *)src;
if (sig)
M_NEG(res.D_s.hi, res.D_s.lo);
return res;
diff --git a/ntpd/ntp.conf.def b/ntpd/ntp.conf.def
index e01fd019c..03dd8b808 100644
--- a/ntpd/ntp.conf.def
+++ b/ntpd/ntp.conf.def
@@ -2945,12 +2945,12 @@ The number can contain other modem control codes as well.
.It Xo Cm pollskewlist
.Oo
.Ar poll
-.Ar value | value
+.Ar early late
.Oc
.Ar ...
.Oo
.Cm default
-.Ar value | value
+.Ar early late
.Oc
.Xc
Enable skewing of our poll requests to our servers.
@@ -2963,9 +2963,11 @@ a poll interval of 17 corresponds to
131,072 seconds, or about a day and a half.
The next two numbers must be between 0 and one-half of the poll interval,
inclusive.
-The first number specifies how early the poll may start,
+Ar early
+specifies how early the poll may start,
while
-the second number specifies how late the poll may be delayed.
+Ar late
+specifies how late the poll may be delayed.
With no arguments, internally specified default values are chosen.
.It Xo Ic reset
.Oo
diff --git a/ntpd/ntp_io.c b/ntpd/ntp_io.c
index c0dcea598..077a5a89f 100644
--- a/ntpd/ntp_io.c
+++ b/ntpd/ntp_io.c
@@ -3240,7 +3240,8 @@ sendpkt(
PKT_MODE(pkt->li_vn_mode),
pkt->stratum,
pkt->ppoll, pkt->precision,
- pkt->rootdelay, pkt->rootdisp, pkt->refid,
+ FPTOD(NTOHS_FP(pkt->rootdelay)),
+ FPTOD(NTOHS_FP(pkt->rootdisp)), pkt->refid,
len - MIN_V4_PKT_LEN, (u_char *)&pkt->exten);
return;
@@ -3403,7 +3404,7 @@ fetch_timestamp(
nts.l_uf = (unsigned long)(ticks * (unsigned long)(sys_tick * FRAC));
}
DPRINTF(4, ("fetch_timestamp: system bintime network time stamp: %ld.%09lu\n",
- pbt.sec, (unsigned long)((nts.l_uf / FRAC) * 1e9)));
+ (long)pbt.sec, (u_long)((nts.l_uf / FRAC) * 1e9)));
}
break;
#endif /* HAVE_BINTIME */
diff --git a/ntpd/ntp_util.c b/ntpd/ntp_util.c
index f3d1c29d8..62a997e43 100644
--- a/ntpd/ntp_util.c
+++ b/ntpd/ntp_util.c
@@ -743,6 +743,13 @@ record_raw_stats(
if (!stats_control)
return;
+ /*
+ * Mode 6 and mode 7 packets do not have the format of normal
+ * NTP packets and will log garbage. So don't. [Bug 3774]
+ */
+ if (MODE_CONTROL == mode || MODE_PRIVATE == mode)
+ return;
+
get_systime(&now);
filegen_setup(&rawstats, now.l_ui);
day = now.l_ui / 86400 + MJD_1900;
diff --git a/ntpdc/ntpdc.c b/ntpdc/ntpdc.c
index 1274e841f..62fcc4806 100644
--- a/ntpdc/ntpdc.c
+++ b/ntpdc/ntpdc.c
@@ -453,8 +453,27 @@ openhost(
#endif
a_info = getaddrinfo(hname, service, &hints, &ai);
}
- /* Some older implementations don't like AI_ADDRCONFIG. */
- if (a_info == EAI_BADFLAGS) {
+ /*
+ * Some older implementations don't like AI_ADDRCONFIG.
+ * Some versions of Windows return WSANO_DATA when there is no
+ * global address and AI_ADDRCONFIG is used. AI_ADDRCONFIG
+ * is useful to short-circuit DNS lookups for IP protocols
+ * for which the host has no local addresses. Windows
+ * unfortunately instead interprets AI_ADDRCONFIG to relate
+ * to off-host connectivity and so fails lookup when
+ * localhost works.
+ * To further muddy matters, some versions of WS2tcpip.h
+ * comment out #define EAI_NODATA WSANODATA claiming it
+ * was removed from RFC 2553bis and mentioning a need to
+ * contact the authors to find out why, but "helpfully"
+ * #defines EAI_NODATA EAI_NONAME (== WSAHOST_NOT_FOUND)
+ * So we get more ugly platform-specific workarounds.
+ */
+ if (
+#if defined(WIN32)
+ WSANO_DATA == a_info || EAI_NONAME == a_info ||
+#endif
+ EAI_BADFLAGS == a_info) {
hints.ai_flags = AI_CANONNAME;
a_info = getaddrinfo(hname, service, &hints, &ai);
}
diff --git a/ntpq/ntpq-subs.c b/ntpq/ntpq-subs.c
index 6a0c5daf5..527be098b 100644
--- a/ntpq/ntpq-subs.c
+++ b/ntpq/ntpq-subs.c
@@ -2022,16 +2022,17 @@ dopeers(
if (!dogetassoc(fp))
return;
- for (u = 0; u < numhosts; u++) {
- if (getnetnum(chosts[u].name, &netnum, fullname, af)) {
- name_or_num = nntohost(&netnum);
- sl = strlen(name_or_num);
- maxhostlen = max(maxhostlen, sl);
+ if (numhosts > 1) {
+ for (u = 0; u < numhosts; u++) {
+ if (getnetnum(chosts[u].name, &netnum, fullname, af)) {
+ name_or_num = nntohost(&netnum);
+ sl = strlen(name_or_num);
+ maxhostlen = max(maxhostlen, sl);
+ }
}
- }
- if (numhosts > 1)
xprintf(fp, "%-*.*s ", (int)maxhostlen, (int)maxhostlen,
"server (local)");
+ }
xprintf(fp,
" remote refid st t when poll reach delay offset jitter\n");
if (numhosts > 1)
@@ -2076,16 +2077,17 @@ doapeers(
if (!dogetassoc(fp))
return;
- for (u = 0; u < numhosts; u++) {
- if (getnetnum(chosts[u].name, &netnum, fullname, af)) {
- name_or_num = nntohost(&netnum);
- sl = strlen(name_or_num);
- maxhostlen = max(maxhostlen, sl);
+ if (numhosts > 1) {
+ for (u = 0; u < numhosts; u++) {
+ if (getnetnum(chosts[u].name, &netnum, fullname, af)) {
+ name_or_num = nntohost(&netnum);
+ sl = strlen(name_or_num);
+ maxhostlen = max(maxhostlen, sl);
+ }
}
- }
- if (numhosts > 1)
xprintf(fp, "%-*.*s ", (int)maxhostlen, (int)maxhostlen,
"server (local)");
+ }
xprintf(fp,
" remote refid assid st t when poll reach delay offset jitter\n");
if (numhosts > 1)
@@ -2198,14 +2200,15 @@ doopeers(
if (!dogetassoc(fp))
return;
- for (i = 0; i < numhosts; ++i) {
- if (getnetnum(chosts[i].name, &netnum, fullname, af))
- if (strlen(fullname) > maxhostlen)
- maxhostlen = strlen(fullname);
+ if (numhosts > 1) {
+ for (i = 0; i < numhosts; ++i) {
+ if (getnetnum(chosts[i].name, &netnum, fullname, af)) {
+ maxhostlen = max(maxhostlen, strlen(fullname));
+ }
+ xprintf(fp, "%-*.*s ", (int)maxhostlen, (int)maxhostlen,
+ "server");
+ }
}
- if (numhosts > 1)
- xprintf(fp, "%-*.*s ", (int)maxhostlen, (int)maxhostlen,
- "server");
xprintf(fp,
" remote local st t when poll reach delay offset disp\n");
if (numhosts > 1)
diff --git a/ntpq/ntpq.c b/ntpq/ntpq.c
index 03a42dfdf..9d48e124f 100644
--- a/ntpq/ntpq.c
+++ b/ntpq/ntpq.c
@@ -721,8 +721,27 @@ openhost(
a_info = getaddrinfo(hname, svc, &hints, &ai);
}
#ifdef AI_ADDRCONFIG
- /* Some older implementations don't like AI_ADDRCONFIG. */
- if (a_info == EAI_BADFLAGS) {
+ /*
+ * Some older implementations don't like AI_ADDRCONFIG.
+ * Some versions of Windows return WSANO_DATA when there is no
+ * global address and AI_ADDRCONFIG is used. AI_ADDRCONFIG
+ * is useful to short-circuit DNS lookups for IP protocols
+ * for which the host has no local addresses. Windows
+ * unfortunately instead interprets AI_ADDRCONFIG to relate
+ * to off-host connectivity and so fails lookup when
+ * localhost works.
+ * To further muddy matters, some versions of WS2tcpip.h
+ * comment out #define EAI_NODATA WSANODATA claiming it
+ * was removed from RFC 2553bis and mentioning a need to
+ * contact the authors to find out why, but "helpfully"
+ * #defines EAI_NODATA EAI_NONAME (== WSAHOST_NOT_FOUND)
+ * So we get more ugly platform-specific workarounds.
+ */
+ if (
+#if defined(WIN32)
+ WSANO_DATA == a_info || EAI_NONAME == a_info ||
+#endif
+ EAI_BADFLAGS == a_info) {
hints.ai_flags &= ~AI_ADDRCONFIG;
a_info = getaddrinfo(hname, svc, &hints, &ai);
}
@@ -3908,7 +3927,7 @@ ntpq_custom_opt_handler(
struct hstate {
char *list;
- const char **seen;
+ char const **seen;
int idx;
};
@@ -3948,7 +3967,7 @@ list_md_fn(const EVP_MD *m, const char *from, const char *to, void *arg)
return;
n = (seen - hstate->seen) + 2;
- hstate->seen = erealloc(hstate->seen, n * sizeof(*seen));
+ hstate->seen = erealloc((void *)hstate->seen, n * sizeof(*seen));
hstate->seen[n-2] = name;
hstate->seen[n-1] = NULL;
@@ -4098,12 +4117,12 @@ list_digest_names(void)
struct hstate hstate = { NULL, NULL, K_PER_LINE+1 };
/* replace calloc(1, sizeof(const char *)) */
- hstate.seen = (const char **)emalloc_zero(sizeof(const char *));
+ hstate.seen = emalloc_zero(sizeof(const char*));
INIT_SSL();
EVP_MD_do_all_sorted(list_md_fn, &hstate);
list = hstate.list;
- free(hstate.seen);
+ free((void *)hstate.seen);
list = insert_cmac(list); /* Insert CMAC into SSL digests list */
diff --git a/ports/winnt/libntp/messages.h b/ports/winnt/libntp/messages.h
index 16197e34f..e29393a02 100644
--- a/ports/winnt/libntp/messages.h
+++ b/ports/winnt/libntp/messages.h
@@ -1,130 +1,9 @@
/*
- Microsoft Developer Support
- Copyright (c) 1992 Microsoft Corporation
-
- This file contains the message definitions for the Win32
- syslog support messages for the nntp firewall
--------------------------------------------------------------------------
- HEADER SECTION
-
- The header section defines names and language identifiers for use
- by the message definitions later in this file. The MessageIdTypedef,
- SeverityNames, FacilityNames, and LanguageNames keywords are
- optional and not required.
-
-
-
- The MessageIdTypedef keyword gives a typedef name that is used in a
- type cast for each message code in the generated include file. Each
- message code appears in the include file with the format: #define
- name ((type) 0xnnnnnnnn) The default value for type is empty, and no
- type cast is generated. It is the programmer's responsibility to
- specify a typedef statement in the application source code to define
- the type. The type used in the typedef must be large enough to
- accomodate the entire 32-bit message code.
-
-
-
- The SeverityNames keyword defines the set of names that are allowed
- as the value of the Severity keyword in the message definition. The
- set is delimited by left and right parentheses. Associated with each
- severity name is a number that, when shifted left by 30, gives the
- bit pattern to logical-OR with the Facility value and MessageId
- value to form the full 32-bit message code. The default value of
- this keyword is:
-
- SeverityNames=(
- Success=0x0
- Informational=0x1
- Warning=0x2
- Error=0x3
- )
-
- Severity values occupy the high two bits of a 32-bit message code.
- Any severity value that does not fit in two bits is an error. The
- severity codes can be given symbolic names by following each value
- with :name
-
-
-FacilityNames=(System=0x0:FACILITY_SYSTEM
- Runtime=0x2:FACILITY_RUNTIME
- Stubs=0x3:FACILITY_STUBS
- Io=0x4:FACILITY_IO_ERROR_CODE
- )
-
- The FacilityNames keyword defines the set of names that are allowed
- as the value of the Facility keyword in the message definition. The
- set is delimited by left and right parentheses. Associated with each
- facility name is a number that, when shift it left by 16 bits, gives
- the bit pattern to logical-OR with the Severity value and MessageId
- value to form the full 32-bit message code. The default value of
- this keyword is:
-
- FacilityNames=(
- System=0x0FF
- Application=0xFFF
- )
-
- Facility codes occupy the low order 12 bits of the high order
- 16-bits of a 32-bit message code. Any facility code that does not
- fit in 12 bits is an error. This allows for 4,096 facility codes.
- The first 256 codes are reserved for use by the system software. The
- facility codes can be given symbolic names by following each value
- with :name
-
-
- The LanguageNames keyword defines the set of names that are allowed
- as the value of the Language keyword in the message definition. The
- set is delimited by left and right parentheses. Associated with each
- language name is a number and a file name that are used to name the
- generated resource file that contains the messages for that
- language. The number corresponds to the language identifier to use
- in the resource table. The number is separated from the file name
- with a colon. The initial value of LanguageNames is:
-
- LanguageNames=(English=1:MSG00001)
-
- Any new names in the source file which don't override the built-in
- names are added to the list of valid languages. This allows an
- application to support private languages with descriptive names.
-
-
--------------------------------------------------------------------------
- MESSAGE DEFINITION SECTION
-
- Following the header section is the body of the Message Compiler
- source file. The body consists of zero or more message definitions.
- Each message definition begins with one or more of the following
- statements:
-
- MessageId = [number|+number]
- Severity = severity_name
- Facility = facility_name
- SymbolicName = name
-
- The MessageId statement marks the beginning of the message
- definition. A MessageID statement is required for each message,
- although the value is optional. If no value is specified, the value
- used is the previous value for the facility plus one. If the value
- is specified as +number then the value used is the previous value
- for the facility, plus the number after the plus sign. Otherwise, if
- a numeric value is given, that value is used. Any MessageId value
- that does not fit in 16 bits is an error.
-
- The Severity and Facility statements are optional. These statements
- specify additional bits to OR into the final 32-bit message code. If
- not specified they default to the value last specified for a message
- definition. The initial values prior to processing the first message
- definition are:
-
- Severity=Success
- Facility=Application
-
- The value associated with Severity and Facility must match one of
- the names given in the FacilityNames and SeverityNames statements in
- the header section. The SymbolicName statement allows you to
- associate a C/C++ symbolic constant with the final 32-bit message
- code.
+ Boilerplate Microsoft copyright statement previously here removed because
+ the code does not posess "at least some minimal degree of creativity".
+
+ https://www.copyright.gov/comp3/chap300/ch300-copyrightable-authorship.pdf
+ Section 308 The Originality Requirement
*/
//
// Values are 32 bit values laid out as follows:
@@ -160,10 +39,6 @@ FacilityNames=(System=0x0:FACILITY_SYSTEM
//
// Define the severity codes
//
-#define STATUS_SEVERITY_SUCCESS 0x0
-#define STATUS_SEVERITY_INFORMATIONAL 0x1
-#define STATUS_SEVERITY_WARNING 0x2
-#define STATUS_SEVERITY_ERROR 0x3
//
@@ -173,7 +48,7 @@ FacilityNames=(System=0x0:FACILITY_SYSTEM
//
// %1
//
-#define NTP_ERROR ((DWORD)0xC0000001L)
+#define NTP_ERROR 0xC0000001L
//
// MessageId: NTP_WARNING
@@ -183,7 +58,7 @@ FacilityNames=(System=0x0:FACILITY_SYSTEM
// %1
//
//
-#define NTP_WARNING ((DWORD)0x80000002L)
+#define NTP_WARNING 0x80000002L
//
// MessageId: NTP_INFO
@@ -195,5 +70,5 @@ FacilityNames=(System=0x0:FACILITY_SYSTEM
//
//
//
-#define NTP_INFO ((DWORD)0x40000003L)
+#define NTP_INFO 0x40000003L
diff --git a/ports/winnt/libntp/messages.mc b/ports/winnt/libntp/messages.mc
index 3a6bc7d22..9eeb76004 100644
--- a/ports/winnt/libntp/messages.mc
+++ b/ports/winnt/libntp/messages.mc
@@ -1,137 +1,9 @@
; /*
-; Microsoft Developer Support
-; Copyright (c) 1992 Microsoft Corporation
-;
-; This file contains the message definitions for the Win32
-; syslog support messages for the nntp firewall
-
-;-------------------------------------------------------------------------
-; HEADER SECTION
-;
-; The header section defines names and language identifiers for use
-; by the message definitions later in this file. The MessageIdTypedef,
-; SeverityNames, FacilityNames, and LanguageNames keywords are
-; optional and not required.
-;
-;
-MessageIdTypedef=DWORD
-;
-; The MessageIdTypedef keyword gives a typedef name that is used in a
-; type cast for each message code in the generated include file. Each
-; message code appears in the include file with the format: #define
-; name ((type) 0xnnnnnnnn) The default value for type is empty, and no
-; type cast is generated. It is the programmer's responsibility to
-; specify a typedef statement in the application source code to define
-; the type. The type used in the typedef must be large enough to
-; accomodate the entire 32-bit message code.
-;
-;
-SeverityNames=(Success=0x0:STATUS_SEVERITY_SUCCESS
- Informational=0x1:STATUS_SEVERITY_INFORMATIONAL
- Warning=0x2:STATUS_SEVERITY_WARNING
- Error=0x3:STATUS_SEVERITY_ERROR
- )
-;
-; The SeverityNames keyword defines the set of names that are allowed
-; as the value of the Severity keyword in the message definition. The
-; set is delimited by left and right parentheses. Associated with each
-; severity name is a number that, when shifted left by 30, gives the
-; bit pattern to logical-OR with the Facility value and MessageId
-; value to form the full 32-bit message code. The default value of
-; this keyword is:
-;
-; SeverityNames=(
-; Success=0x0
-; Informational=0x1
-; Warning=0x2
-; Error=0x3
-; )
-;
-; Severity values occupy the high two bits of a 32-bit message code.
-; Any severity value that does not fit in two bits is an error. The
-; severity codes can be given symbolic names by following each value
-; with :name
-;
-;
-;FacilityNames=(System=0x0:FACILITY_SYSTEM
-; Runtime=0x2:FACILITY_RUNTIME
-; Stubs=0x3:FACILITY_STUBS
-; Io=0x4:FACILITY_IO_ERROR_CODE
-; )
-;
-; The FacilityNames keyword defines the set of names that are allowed
-; as the value of the Facility keyword in the message definition. The
-; set is delimited by left and right parentheses. Associated with each
-; facility name is a number that, when shift it left by 16 bits, gives
-; the bit pattern to logical-OR with the Severity value and MessageId
-; value to form the full 32-bit message code. The default value of
-; this keyword is:
-;
-; FacilityNames=(
-; System=0x0FF
-; Application=0xFFF
-; )
-;
-; Facility codes occupy the low order 12 bits of the high order
-; 16-bits of a 32-bit message code. Any facility code that does not
-; fit in 12 bits is an error. This allows for 4,096 facility codes.
-; The first 256 codes are reserved for use by the system software. The
-; facility codes can be given symbolic names by following each value
-; with :name
-;
-;
-; The LanguageNames keyword defines the set of names that are allowed
-; as the value of the Language keyword in the message definition. The
-; set is delimited by left and right parentheses. Associated with each
-; language name is a number and a file name that are used to name the
-; generated resource file that contains the messages for that
-; language. The number corresponds to the language identifier to use
-; in the resource table. The number is separated from the file name
-; with a colon. The initial value of LanguageNames is:
-;
-; LanguageNames=(English=1:MSG00001)
-;
-; Any new names in the source file which don't override the built-in
-; names are added to the list of valid languages. This allows an
-; application to support private languages with descriptive names.
-;
-;
-;-------------------------------------------------------------------------
-; MESSAGE DEFINITION SECTION
-;
-; Following the header section is the body of the Message Compiler
-; source file. The body consists of zero or more message definitions.
-; Each message definition begins with one or more of the following
-; statements:
-;
-; MessageId = [number|+number]
-; Severity = severity_name
-; Facility = facility_name
-; SymbolicName = name
-;
-; The MessageId statement marks the beginning of the message
-; definition. A MessageID statement is required for each message,
-; although the value is optional. If no value is specified, the value
-; used is the previous value for the facility plus one. If the value
-; is specified as +number then the value used is the previous value
-; for the facility, plus the number after the plus sign. Otherwise, if
-; a numeric value is given, that value is used. Any MessageId value
-; that does not fit in 16 bits is an error.
-;
-; The Severity and Facility statements are optional. These statements
-; specify additional bits to OR into the final 32-bit message code. If
-; not specified they default to the value last specified for a message
-; definition. The initial values prior to processing the first message
-; definition are:
-;
-; Severity=Success
-; Facility=Application
-;
-; The value associated with Severity and Facility must match one of
-; the names given in the FacilityNames and SeverityNames statements in
-; the header section. The SymbolicName statement allows you to
-; associate a C/C++ symbolic constant with the final 32-bit message
-; code.
+; Boilerplate Microsoft copyright statement previously here removed because
+; the code does not posess "at least some minimal degree of creativity".
+;
+; https://www.copyright.gov/comp3/chap300/ch300-copyrightable-authorship.pdf
+; Section 308 The Originality Requirement
; */
MessageId=0x1
diff --git a/sntp/include/copyright.def b/sntp/include/copyright.def
index 9334ac8da..07b0b9870 100644
--- a/sntp/include/copyright.def
+++ b/sntp/include/copyright.def
@@ -1,7 +1,7 @@
/* -*- Mode: Text -*- */
copyright = {
- date = "1992-2020";
+ date = "1992-2023";
owner = "The University of Delaware and Network Time Foundation";
eaddr = "http://bugs.ntp.org, bugs@ntp.org";
type = ntp;
diff --git a/tests/libntp/decodenetnum.c b/tests/libntp/decodenetnum.c
index 961ea6d30..8f30eb236 100644
--- a/tests/libntp/decodenetnum.c
+++ b/tests/libntp/decodenetnum.c
@@ -36,10 +36,10 @@ test_IPv4AddressOnly(void)
{
const char *str = "192.0.2.1";
sockaddr_u actual;
-
sockaddr_u expected;
- memset(&expected, 0, sizeof(expected));
- expected.sa4.sin_family = AF_INET;
+
+ ZERO(expected);
+ AF(&expected) = AF_INET;
expected.sa4.sin_addr.s_addr = inet_addr("192.0.2.1");
SET_PORT(&expected, NTP_PORT);
@@ -52,10 +52,10 @@ test_IPv4AddressWithPort(void)
{
const char *str = "192.0.2.2:2000";
sockaddr_u actual;
-
sockaddr_u expected;
- memset(&expected, 0, sizeof(expected));
- expected.sa4.sin_family = AF_INET;
+
+ ZERO(expected);
+ AF(&expected) = AF_INET;
expected.sa4.sin_addr.s_addr = inet_addr("192.0.2.2");
SET_PORT(&expected, 2000);
@@ -69,21 +69,21 @@ test_IPv6AddressOnly(void)
{
#if defined(ISC_PLATFORM_HAVEIPV6) && defined(WANT_IPV6)
- const struct in6_addr address = {
+ const struct in6_addr address = { { {
0x20, 0x01, 0x0d, 0xb8,
0x85, 0xa3, 0x08, 0xd3,
0x13, 0x19, 0x8a, 0x2e,
0x03, 0x70, 0x73, 0x34
- };
+ } } };
- const char *str1 = "2001:0db8:85a3:08d3:1319:8a2e:0370:7334";
- const char *str2 = "[2001:0db8:85a3:08d3:1319:8a2e:0370:7334]";
+ const char *str1 = "2001:db8:85a3:08d3:1319:8a2e:0370:7334";
+ const char *str2 = "[2001:0db8:85a3:8d3:1319:8a2e:370:7334]";
sockaddr_u actual;
-
sockaddr_u expected;
- memset(&expected, 0, sizeof(expected));
- expected.sa6.sin6_family = AF_INET6;
- expected.sa6.sin6_addr = address;
+
+ ZERO(expected);
+ AF(&expected) = AF_INET6;
+ SET_ADDR6N(&expected, address);
SET_PORT(&expected, NTP_PORT);
TEST_ASSERT_TRUE(decodenetnum(str1, &actual));
@@ -105,20 +105,20 @@ test_IPv6AddressWithPort(void)
{
#if defined(ISC_PLATFORM_HAVEIPV6) && defined(WANT_IPV6)
- const struct in6_addr address = {
+ const struct in6_addr address = { { {
0x20, 0x01, 0x0d, 0xb8,
0x85, 0xa3, 0x08, 0xd3,
0x13, 0x19, 0x8a, 0x2e,
0x03, 0x70, 0x73, 0x34
- };
+ } } };
const char *str = "[2001:0db8:85a3:08d3:1319:8a2e:0370:7334]:3000";
sockaddr_u actual;
-
sockaddr_u expected;
- memset(&expected, 0, sizeof(expected));
- expected.sa6.sin6_family = AF_INET6;
- expected.sa6.sin6_addr = address;
+
+ ZERO(expected);
+ AF(&expected) = AF_INET6;
+ SET_ADDR6N(&expected, address);
SET_PORT(&expected, 3000);
TEST_ASSERT_TRUE(decodenetnum(str, &actual));
@@ -135,22 +135,22 @@ void test_IPv6AddressWithScope(void)
{
#if defined(ISC_PLATFORM_HAVEIPV6) && defined(WANT_IPV6)
- const struct in6_addr address = {
+ const struct in6_addr address = { { {
0x20, 0x01, 0x0d, 0xb8,
0x85, 0xa3, 0x08, 0xd3,
0x13, 0x19, 0x8a, 0x2e,
0x03, 0x70, 0x73, 0x34
- };
+ } } };
- const char *str1 = "2001:0db8:85a3:08d3:1319:8a2e:0370:7334%42";
+ const char *str1 = "2001:db8:85a3:8d3:1319:8a2e:370:7334%42";
const char *str2 = "[2001:0db8:85a3:08d3:1319:8a2e:0370:7334%42]";
sockaddr_u actual;
-
sockaddr_u expected;
- memset(&expected, 0, sizeof(expected));
- expected.sa6.sin6_family = AF_INET6;
- expected.sa6.sin6_addr = address;
- expected.sa6.sin6_scope_id = 42;
+
+ ZERO(expected);
+ AF(&expected) = AF_INET6;
+ SET_ADDR6N(&expected, address);
+ SET_SCOPE(&expected, 42);
SET_PORT(&expected, NTP_PORT);
TEST_ASSERT_TRUE(decodenetnum(str1, &actual));
@@ -170,21 +170,21 @@ void test_IPv6AddressWithPortAndScope(void)
{
#if defined(ISC_PLATFORM_HAVEIPV6) && defined(WANT_IPV6)
- const struct in6_addr address = {
+ const struct in6_addr address = { { {
0x20, 0x01, 0x0d, 0xb8,
0x85, 0xa3, 0x08, 0xd3,
0x13, 0x19, 0x8a, 0x2e,
0x03, 0x70, 0x73, 0x34
- };
+ } } };
- const char *str = "[2001:0db8:85a3:08d3:1319:8a2e:0370:7334%42]:3000";
+ const char *str = "[2001:db8:85a3:08d3:1319:8a2e:370:7334%42]:3000";
sockaddr_u actual;
-
sockaddr_u expected;
- memset(&expected, 0, sizeof(expected));
- expected.sa6.sin6_family = AF_INET6;
- expected.sa6.sin6_addr = address;
- expected.sa6.sin6_scope_id = 42;
+
+ ZERO(expected);
+ AF(&expected) = AF_INET6;
+ SET_ADDR6N(&expected, address);
+ SET_SCOPE(&expected, 42);
SET_PORT(&expected, 3000);
TEST_ASSERT_TRUE(decodenetnum(str, &actual));
@@ -215,10 +215,10 @@ test_IllegalCharInPort(void)
*/
const char *str = "192.0.2.1:a700";
sockaddr_u actual;
-
sockaddr_u expected;
- memset(&expected, 0, sizeof(expected));
- expected.sa4.sin_family = AF_INET;
+
+ ZERO(expected);
+ AF(&expected) = AF_INET;
expected.sa4.sin_addr.s_addr = inet_addr("192.0.2.1");
SET_PORT(&expected, NTP_PORT);
@@ -232,7 +232,7 @@ test_NameBufOverflow(void)
const char *str =
"loremipsumloremipsumloremipsumloremipsumloremipsum"
"loremipsumloremipsumloremipsumloremipsum";
-
sockaddr_u actual;
+
TEST_ASSERT_FALSE(decodenetnum(str, &actual));
}
diff --git a/tests/libntp/socktoa.c b/tests/libntp/socktoa.c
index c8a9157d9..72de4e9cd 100644
--- a/tests/libntp/socktoa.c
+++ b/tests/libntp/socktoa.c
@@ -38,20 +38,20 @@ test_IPv6AddressWithPort(void)
{
#if defined(ISC_PLATFORM_HAVEIPV6) && defined(WANT_IPV6)
- const struct in6_addr address = {
+ const struct in6_addr address = { { {
0x20, 0x01, 0x0d, 0xb8,
- 0x85, 0xa3, 0x08, 0xd3,
+ 0x85, 0xa3, 0x08, 0xd3,
0x13, 0x19, 0x8a, 0x2e,
0x03, 0x70, 0x73, 0x34
- };
+ } } };
const char* expected =
"2001:db8:85a3:8d3:1319:8a2e:370:7334";
const char* expected_port =
"[2001:db8:85a3:8d3:1319:8a2e:370:7334]:123";
-
sockaddr_u input;
- memset(&input, 0, sizeof(input));
+
+ ZERO(input);
AF(&input) = AF_INET6;
SET_ADDR6N(&input, address);
SET_PORT(&input, 123);
@@ -71,7 +71,7 @@ void
test_ScopedIPv6AddressWithPort(void)
{
#if defined(ISC_PLATFORM_HAVESCOPEID) && defined(WANT_IPV6)
-
+
const struct in6_addr address = { { {
0xfe, 0x80, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
@@ -83,9 +83,9 @@ test_ScopedIPv6AddressWithPort(void)
"fe80::212:3fff:fe29:fffa%5";
const char* expected_port =
"[fe80::212:3fff:fe29:fffa%5]:123";
-
sockaddr_u input;
- memset(&input, 0, sizeof(input));
+
+ ZERO(input);
AF(&input) = AF_INET6;
SET_ADDR6N(&input, address);
SET_PORT(&input, 123);
@@ -129,12 +129,12 @@ test_IgnoreIPv6Fields(void)
{
#if defined(ISC_PLATFORM_HAVEIPV6) && defined(WANT_IPV6)
- const struct in6_addr address = {
- 0x20, 0x01, 0x0d, 0xb8,
- 0x85, 0xa3, 0x08, 0xd3,
- 0x13, 0x19, 0x8a, 0x2e,
- 0x03, 0x70, 0x73, 0x34
- };
+ const struct in6_addr address = { { {
+ 0xfe, 0x80, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+ 0x02, 0x12, 0x3f, 0xff,
+ 0xfe, 0x29, 0xff, 0xfa
+ } } };
sockaddr_u input1, input2;