]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
Bugs 3774 and 3793
authorDave Hart <hart@ntp.org>
Thu, 23 Feb 2023 09:55:50 +0000 (04:55 -0500)
committerDave Hart <hart@ntp.org>
Thu, 23 Feb 2023 09:55:50 +0000 (04:55 -0500)
[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

17 files changed:
ChangeLog
html/copyright.html
html/miscopt.html
include/vint64ops.h
libntp/socktoa.c
libntp/vint64ops.c
ntpd/ntp.conf.def
ntpd/ntp_io.c
ntpd/ntp_util.c
ntpdc/ntpdc.c
ntpq/ntpq-subs.c
ntpq/ntpq.c
ports/winnt/libntp/messages.h
ports/winnt/libntp/messages.mc
sntp/include/copyright.def
tests/libntp/decodenetnum.c
tests/libntp/socktoa.c

index 6fef4f5815fd9af3884b014a2eace27aaacf378d..5d076c62c53d1d7bd763a96e6372d1787d24fd9f 100644 (file)
--- 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. <hart@ntp.org>
+* [Bug 3797] Windows getaddrinfo w/AI_ADDRCONFIG fails for localhost when 
+             disconnected, breaking ntpq and ntpdc. <hart@ntp.org>
+* [Bug 3774] mode 6 packets corrupted in rawstats file <hart@ntp.org>
+  - Reported by Edward McGuire, fix identified by <wei6410@sina.com>.
+* [Bug 3793] Wrong variable type passed to record_raw_stats(). <hart@ntp.org>
+  - Report and patch by Yuezhen LUAN <wei6410@sina.com>.
 * [Bug 3640] document "discard monitor" and fix the code. <hart@ntp.org>
   - fixed bug identified by Edward McGuire <perlinger@ntp.org>
 * [Bug 3660] Revert 4.2.8p15 change to manycast. <hart@ntp.org>
index e28b976aa4e9c7c8c18a8fd6e19cb2810e8ab0d9..86c56dc9a427bc6636cfcf84ca12e2d81f64d593 100644 (file)
@@ -9,7 +9,7 @@
 <h3>Copyright Notice</h3>
 <img src="pic/sheepb.jpg" alt="jpg" align="left"> "Clone me," says Dolly sheepishly.
 <p>Last update:
-  <!-- #BeginDate format:En2m -->4-Feb-2020  23:47<!-- #EndDate -->
+  <!-- #BeginDate format:En2m -->22-Feb-2023  22:35<!-- #EndDate -->
     UTC</p>
 <br clear="left">
 </p>
@@ -38,7 +38,7 @@
 <pre>
 ***********************************************************************
 *                                                                     *
-* Copyright (c) Network Time Foundation 2011-2020                     *
+* Copyright (c) Network Time Foundation 2011-2023                     *
 *                                                                     *
 * All Rights Reserved                                                 *
 *                                                                     *
index f5bce4b44ac3b8363dfc5b5e7054d3a344cdbbc8..ecbe25fc4addf7a5472ffc068f3e0a9a776b95d5 100644 (file)
       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&nbsp;is normally prepended to the number, which can contain other modem control codes as well.</dd>
   <dt id="pollskewlist"
-  ><tt>pollskewlist</tt> <tt>[</tt><i>poll</i> <i>value</i><tt>
-  | </tt><i>value</i><tt>]</tt> <tt>...</tt> <tt>[default </tt><i>value</i><tt>
-  | </tt><i>value</i><tt>]</tt></dt>
+  ><tt>pollskewlist</tt> <tt>[</tt><i>poll</i> <i>early late</i><tt>]</tt> <tt>...</tt> <tt>[default </tt><i>early late</i><tt>]</tt></dt>
 <dd>Enable skewing of our poll requests to our servers. 
 <i>poll</i>
 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. 
+<i>early</i> specifies how early the poll may start, while
+<i>late</i> specifies how late the poll may be delayed. 
 With no arguments, internally specified default values are chosen.</dd>
   <dt id="reset"><tt>reset [allpeers] [auth] [ctl] [io] [mem] [sys] [timer]</tt></dt>
   <dd>Reset one or more groups of counters maintained by ntpd and exposed by <tt>ntpq</tt> and <tt>ntpdc</tt>.</dd>
index 2c3deffb3813266f5e4065f435a54d8ff304e4e2..7c245b963285c6cf051ffba50362e353bd70a5ba 100644 (file)
@@ -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)*/
index 98abe7c420360977f182534d7f64f95dde8a3bb9..4071b0a45be061ad64557aca921bc4beb3af0c72 100644 (file)
@@ -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;
index 5adbebbb51d4024d574fc78838bbbc2713156072..f4fc47fe71430f9978ce7db1ae207d20d90cb005 100644 (file)
 #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;
index e01fd019cc447d29ffc8aad8ea9ff7afa5d868f9..03dd8b80809951f4731dda5c71fa94209ac166e0 100644 (file)
@@ -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
index c0dcea598121e72a6fa3a7a11a65a37d22b85c62..077a5a89f2d06a85eca5e9a71b2074f06aeba9b1 100644 (file)
@@ -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 */
index f3d1c29d8eb8ab09220ced28a44ea4ddc5f61f6c..62a997e43aad0b8983a99ab02b91230200d627d6 100644 (file)
@@ -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;
index 1274e841fb66ad41aec5c559861ee48aef9298f0..62fcc480655dd68225aad06e3dbcbe63fde71e34 100644 (file)
@@ -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);      
        }
index 6a0c5daf58fb9e25708b399eb7707b3b42b4b392..527be098b5611cfe526a7d2b89ed08743ec6dfe9 100644 (file)
@@ -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)
index 03a42dfdfb468ae8796441814ba2c647809857b4..9d48e124fcc3d2f9882d20417fdd12d4c1cf8e76 100644 (file)
@@ -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 */
 
index 16197e34fdee31a2a8d1d39418d45bff6bd7eaf7..e29393a02497579d5dfe3a19d1e94a066a5392d3 100644 (file)
@@ -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
 
index 3a6bc7d22c0fa607b4cb385a37447781239030e5..9eeb760043f487c0566411e9a49fe5b5af901418 100644 (file)
@@ -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
index 9334ac8da8160a692cb07a1e2b56d358364dcd63..07b0b9870f0189542e811ba60660083eb41af3ad 100644 (file)
@@ -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;
index 961ea6d308c97d6af407acf06d0ea5ce5d2a7d3c..8f30eb236a9dcde125752a9910618a62db006ff9 100644 (file)
@@ -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));
 }
index c8a9157d9bfa611cc8130de972b6078d40fd2bc4..72de4e9cdcd40905abeacf269b19b5935598d5fe 100644 (file)
@@ -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;