]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 1261] CID 34: simulate_server() rbuf.msg_flags uninitialized.
authorDave Hart <hart@ntp.org>
Sat, 25 Jul 2009 01:12:25 +0000 (01:12 +0000)
committerDave Hart <hart@ntp.org>
Sat, 25 Jul 2009 01:12:25 +0000 (01:12 +0000)
[Bug 1262] CID 35: xpkt.mac uninitialized in simulate_server().
[Bug 1263] CID 37: CID 38: CID 40: CID 43: multiple refclocks
  uninitialized tm_zone (arc, chronolog, dumbclock, pcf).
[Bug 1264] CID 64: gsoc_sntp on_wire() frees wrong ptr receiving KoD.
[Bug 1265] CID 65: CID 66: gsoc_sntp on_wire() leaks x_pkt, r_pkt.
[Bug 1266] CID 39: datum_pts_start() uninitialized arg.c_ospeed.
[Bug 1267] CID 44: old sntp handle_saving() writes stack garbage to
  file when clearing.
[Bug 1268] CID 63: resolve_hosts() leaks error message buffer.
[Bug 1269] CID 74: use assertion to ensure move_fd() does not return
  negative descriptors.
[Bug 1270] CID 70: gsoc_sntp recv_bcst_data mdevadr.ipv6mr_interface
  uninitialized.

bk: 4a6a5bf9iESzUtFlAYPYeVC3P7qySQ

14 files changed:
ChangeLog
gsoc_sntp/main.c
gsoc_sntp/networking.c
ntpd/ntp_io.c
ntpd/ntpsim.c
ntpd/refclock_arc.c
ntpd/refclock_chronolog.c
ntpd/refclock_datum.c
ntpd/refclock_dumbclock.c
ntpd/refclock_pcf.c
ports/winnt/include/config.h
ports/winnt/ntpd/ntpd.dsp
ports/winnt/ntpd/ntpd.vcproj
sntp/main.c

index f4c701589925ea3134bd9331df4f9767bf77df13..eff8f1f61e13086e8b412ba1e4e8130502cb1d85 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+* [Bug 1261] CID 34: simulate_server() rbuf.msg_flags uninitialized.
+* [Bug 1262] CID 35: xpkt.mac uninitialized in simulate_server().
+* [Bug 1263] CID 37: CID 38: CID 40: CID 43: multiple refclocks 
+  uninitialized tm_zone (arc, chronolog, dumbclock, pcf).
+* [Bug 1264] CID 64: gsoc_sntp on_wire() frees wrong ptr receiving KoD.
+* [Bug 1265] CID 65: CID 66: gsoc_sntp on_wire() leaks x_pkt, r_pkt.
+* [Bug 1266] CID 39: datum_pts_start() uninitialized arg.c_ospeed.
+* [Bug 1267] CID 44: old sntp handle_saving() writes stack garbage to
+  file when clearing.
+* [Bug 1268] CID 63: resolve_hosts() leaks error message buffer.
+* [Bug 1269] CID 74: use assertion to ensure move_fd() does not return
+  negative descriptors.
+* [Bug 1270] CID 70: gsoc_sntp recv_bcst_data mdevadr.ipv6mr_interface
+  uninitialized.
 (4.2.5p192) 2009/07/24 Released by Harlan Stenn <stenn@ntp.org>
 * [Bug 965] CID 42: ss_family uninitialized.
 * [Bug 1250] CID 53: kod_init_kod_db() overruns kod_db malloc'd buffer.
index 81b0e01b1352852839db64574da0c7cc464ce1ea..39353c42e544e945e91047915d96ee4844da10db 100644 (file)
@@ -153,21 +153,18 @@ on_wire (
 {
        register int try;
        SOCKET sock;
+       struct pkt *x_pkt = (struct pkt *) alloca(sizeof(struct pkt));
+       struct pkt *r_pkt = (struct pkt *) alloca(sizeof(struct pkt));
        
        for(try=0; try<5; try++) {
-               struct pkt *x_pkt = (struct pkt *) malloc(sizeof(struct pkt));
-               struct pkt *r_pkt = (struct pkt *) malloc(sizeof(struct pkt));
-
                struct timeval tv_xmt, tv_dst;
-       
                double t21, t34, delta, offset;
-
                int error, rpktl, sw_case;
-
                char *hostname = NULL, *ts_str = NULL;
-
                l_fp p_rec, p_xmt, p_ref, p_org, xmt, tmp, dst;
 
+               memset(r_pkt, 0, sizeof(*r_pkt));
+               memset(x_pkt, 0, sizeof(*x_pkt));
 
                error = GETTIMEOFDAY(&tv_xmt, (struct timezone *)NULL);
 
@@ -219,13 +216,13 @@ on_wire (
                                                        (char *) r_pkt->refid, hostname);
 
                                char *log_str = (char *) malloc(sizeof(char) * (INET6_ADDRSTRLEN + 72));
-                               snprintf(log_str, (INET6_ADDRSTRLEN + 72), 
+                               snprintf(log_str, sizeof(log_str), 
                                        "Received a KOD packet with code %s from %s, demobilizing all connections", 
                                        (char *) &r_pkt->refid, hostname);
 
                                log_msg(log_str, 2);
 
-                               free(log_msg);
+                               free(log_str);
                                break;
 
                        case KOD_RATE:
@@ -308,7 +305,7 @@ on_wire (
        char logmsg[32 + INET6_ADDRSTRLEN];
        getnameinfo(host->ai_addr, host->ai_addrlen, adr_buf, sizeof(adr_buf), NULL, 0, NI_NUMERICHOST);
 
-       snprintf(logmsg, 32 + INET6_ADDRSTRLEN, "Received no useable packet from %s!", adr_buf);
+       snprintf(logmsg, sizeof(logmsg), "Received no useable packet from %s!", adr_buf);
 
        if(ENABLED_OPT(NORMALVERBOSE))
                printf("sntp on_wire: Received no useable packet from %s!\n", adr_buf);
index 33b2d4f4684e6a7c5ee99f2b0980f7c3ea4c2cf3..2049e59e22fd36b2d3b5b7cb9ae45af7cdd028e0 100644 (file)
@@ -74,6 +74,7 @@ resolve_hosts (
 #endif
 
                        log_msg(logmsg, 1);
+                       free(logmsg);
                } else {
 #ifdef DEBUG
                        for (dres = tres[resc]; dres; dres = dres->ai_next) {
@@ -251,10 +252,9 @@ recv_bcst_data (
                        return BROADCAST_FAILED;
                }
 
+               memset(&mdevadr, 0, sizeof(mdevadr));
                mdevadr.ipv6mr_multiaddr = SOCK_ADDR6(sas);
-               /* FIXME    hat value for ipv6mr_interface?  Use utilities for sock to char op*/
-               /* mdevadr.ipv6mr_interface = in6addr_any; */ 
-                                                                                                                
+
                if(!IN6_IS_ADDR_MULTICAST(&mdevadr.ipv6mr_multiaddr)) {
                        if(ENABLED_OPT(NORMALVERBOSE)) {
                                buf = ss_to_str(sas); 
index 12732d4cd45692a0ba1ec563f12e811426bffd44..af7c971f8ee2b0a0107c134f65715b858d7cfcda 100644 (file)
@@ -375,6 +375,8 @@ move_fd(
        SOCKET fd
        )
 {
+       NTP_REQUIRE((int)fd >= 0);
+
 #if !defined(SYS_WINNT) && defined(F_DUPFD)
 #ifndef FD_CHUNK
 #define FD_CHUNK       10
index e8adc3196af4e1e0cad5598ae123ec7d5f28460a..e7c0d9a583c94c7acf904b99fcd0aebc82c7798e 100644 (file)
@@ -222,6 +222,9 @@ int simulate_server(
     double d1, d2, d3;        /* Delays while the packet is enroute */
     double t1, t2, t3, t4;     /* The four timestamps in the packet */
 
+    memset(&xpkt, 0, sizeof(xpkt));
+    memset(&rbuf, 0, sizeof(rbuf));
+
     /* Search for the server with the desired address */
     server = NULL;
     for (i = 0; i < simulation.num_of_servers; ++i) {
index af10c9faad00e2c6e577ef0db1fc9f53d8db8cb2..7f1fcbf507b51fa20b40fdbec73324f5502b0cbc 100644 (file)
@@ -138,27 +138,27 @@ GENERAL
  2) PRECISION should be -4/-5 (63ms/31ms) for the following reasons:
 
      a) The ARC documentation claims the internal clock is (only)
-        accurate to about 20ms relative to Rugby (plus there must be
-        noticable drift and delay in the ms range due to transmission
-        delays and changing atmospheric effects).  This clock is not
-        designed for ms accuracy as NTP has spoilt us all to expect.
+       accurate to about 20ms relative to Rugby (plus there must be
+       noticable drift and delay in the ms range due to transmission
+       delays and changing atmospheric effects).  This clock is not
+       designed for ms accuracy as NTP has spoilt us all to expect.
 
      b) The clock oscillator looks like a simple uncompensated quartz
-        crystal of the sort used in digital watches (ie 32768Hz) which
-        can have large temperature coefficients and drifts; it is not
-        clear if this oscillator is properly disciplined to the MSF
-        transmission, but as the default is to resync only once per
-        *day*, we can imagine that it is not, and is free-running.  We
-        can minimise drift by resyncing more often (at the cost of
-        reduced battery life), but drift/wander may still be
-        significant.
+       crystal of the sort used in digital watches (ie 32768Hz) which
+       can have large temperature coefficients and drifts; it is not
+       clear if this oscillator is properly disciplined to the MSF
+       transmission, but as the default is to resync only once per
+       *day*, we can imagine that it is not, and is free-running.  We
+       can minimise drift by resyncing more often (at the cost of
+       reduced battery life), but drift/wander may still be
+       significant.
 
      c) Note that the bit time of 3.3ms adds to the potential error in
-        the the clock timestamp, since the bit clock of the serial link
-        may effectively be free-running with respect to the host clock
-        and the MSF clock.  Actually, the error is probably 1/16th of
-        the above, since the input data is probably sampled at at least
-        16x the bit rate.
+       the the clock timestamp, since the bit clock of the serial link
+       may effectively be free-running with respect to the host clock
+       and the MSF clock.  Actually, the error is probably 1/16th of
+       the above, since the input data is probably sampled at at least
+       16x the bit rate.
 
     By keeping the clock marked as not very precise, it will have a
     fairly large dispersion, and thus will tend to be used as a
@@ -178,9 +178,9 @@ GENERAL
     IN ANY CASE, BE SURE TO SET AN APPROPRIATE FUDGE FACTOR TO REMOVE
     ANY RESIDUAL SKEW, eg:
 
-        server 127.127.27.0 # ARCRON MSF radio clock unit 0.
-        # Fudge timestamps by about 20ms.
-        fudge 127.127.27.0 time1 0.020
+       server 127.127.27.0 # ARCRON MSF radio clock unit 0.
+       # Fudge timestamps by about 20ms.
+       fudge 127.127.27.0 time1 0.020
 
     You will need to observe your system's behaviour, assuming you have
     some other NTP source to compare it with, to work out what the
@@ -317,28 +317,28 @@ You have to wait for character echo + 10ms before sending next character.
 /* 12. year tens */
 /* 13. year units */
 /* 14. BST/UTC status */
-/*      bit 7   parity */
-/*      bit 6   always 0 */
-/*      bit 5   always 1 */
-/*      bit 4   always 1 */
-/*      bit 3   always 0 */
-/*      bit 2   =1 if UTC is in effect, complementary to the BST bit */
-/*      bit 1   =1 if BST is in effect, according to the BST bit     */
-/*      bit 0   BST/UTC change impending bit=1 in case of change impending */
+/*     bit 7   parity */
+/*     bit 6   always 0 */
+/*     bit 5   always 1 */
+/*     bit 4   always 1 */
+/*     bit 3   always 0 */
+/*     bit 2   =1 if UTC is in effect, complementary to the BST bit */
+/*     bit 1   =1 if BST is in effect, according to the BST bit     */
+/*     bit 0   BST/UTC change impending bit=1 in case of change impending */
 /* 15. status */
-/*      bit 7   parity */
-/*      bit 6   always 0 */
-/*      bit 5   always 1 */
-/*      bit 4   always 1 */
-/*      bit 3   =1 if low battery is detected */
-/*      bit 2   =1 if the very last reception attempt failed and a valid */
-/*              time information already exists (bit0=1) */
-/*              =0 if the last reception attempt was successful */
-/*      bit 1   =1 if at least one reception since 2:30 am was successful */
-/*              =0 if no reception attempt since 2:30 am was successful */
-/*      bit 0   =1 if the RC Computer Clock contains valid time information */
-/*              This bit is zero after reset and one after the first */
-/*              successful reception attempt */
+/*     bit 7   parity */
+/*     bit 6   always 0 */
+/*     bit 5   always 1 */
+/*     bit 4   always 1 */
+/*     bit 3   =1 if low battery is detected */
+/*     bit 2   =1 if the very last reception attempt failed and a valid */
+/*             time information already exists (bit0=1) */
+/*             =0 if the last reception attempt was successful */
+/*     bit 1   =1 if at least one reception since 2:30 am was successful */
+/*             =0 if no reception attempt since 2:30 am was successful */
+/*     bit 0   =1 if the RC Computer Clock contains valid time information */
+/*             This bit is zero after reset and one after the first */
+/*             successful reception attempt */
 
 /* DHD note:
 Also note g<cr> command which confirms that a resync is in progress, and
@@ -375,15 +375,15 @@ Also note h<cr> command which starts a resync to MSF signal.
 /*
  * Interface definitions
  */
-#define DEVICE          "/dev/arc%d"    /* Device name and unit. */
-#define SPEED           B300            /* UART speed (300 baud) */
-#define PRECISION       (-4)            /* Precision  (~63 ms). */
-#define HIGHPRECISION   (-5)            /* If things are going well... */
-#define REFID           "MSFa"          /* Reference ID. */
-#define REFID_MSF       "MSF"           /* Reference ID. */
-#define REFID_DCF77     "DCF"           /* Reference ID. */
-#define REFID_WWVB      "WWVB"          /* Reference ID. */
-#define DESCRIPTION     "ARCRON MSF/DCF/WWVB Receiver"
+#define DEVICE         "/dev/arc%d"    /* Device name and unit. */
+#define SPEED          B300            /* UART speed (300 baud) */
+#define PRECISION      (-4)            /* Precision  (~63 ms). */
+#define HIGHPRECISION  (-5)            /* If things are going well... */
+#define REFID          "MSFa"          /* Reference ID. */
+#define REFID_MSF      "MSF"           /* Reference ID. */
+#define REFID_DCF77    "DCF"           /* Reference ID. */
+#define REFID_WWVB     "WWVB"          /* Reference ID. */
+#define DESCRIPTION    "ARCRON MSF/DCF/WWVB Receiver"
 
 #ifdef PRE_NTP420
 #define MODE ttlmax
@@ -391,13 +391,13 @@ Also note h<cr> command which starts a resync to MSF signal.
 #define MODE ttl
 #endif
 
-#define LENARC          16              /* Format `o' timecode length. */
+#define LENARC         16              /* Format `o' timecode length. */
 
-#define BITSPERCHAR     11              /* Bits per character. */
-#define BITTIME         0x0DA740E       /* Time for 1 bit at 300bps. */
-#define CHARTIME10      0x8888888       /* Time for 10-bit char at 300bps. */
-#define CHARTIME11      0x962FC96       /* Time for 11-bit char at 300bps. */
-#define CHARTIME                        /* Time for char at 300bps. */ \
+#define BITSPERCHAR    11              /* Bits per character. */
+#define BITTIME                0x0DA740E       /* Time for 1 bit at 300bps. */
+#define CHARTIME10     0x8888888       /* Time for 10-bit char at 300bps. */
+#define CHARTIME11     0x962FC96       /* Time for 11-bit char at 300bps. */
+#define CHARTIME                       /* Time for char at 300bps. */ \
 ( (BITSPERCHAR == 11) ? CHARTIME11 : ( (BITSPERCHAR == 10) ? CHARTIME10 : \
                                       (BITSPERCHAR * BITTIME) ) )
 
@@ -457,12 +457,12 @@ Also note h<cr> command which starts a resync to MSF signal.
 #endif
      };
 
-#define DEFAULT_RESYNC_TIME  (57*60)    /* Gap between resync attempts (s). */
-#define RETRY_RESYNC_TIME    (27*60)    /* Gap to emergency resync attempt. */
+#define DEFAULT_RESYNC_TIME  (57*60)   /* Gap between resync attempts (s). */
+#define RETRY_RESYNC_TIME    (27*60)   /* Gap to emergency resync attempt. */
 #ifdef ARCRON_KEEN
-#define INITIAL_RESYNC_DELAY 500        /* Delay before first resync. */
+#define INITIAL_RESYNC_DELAY 500       /* Delay before first resync. */
 #else
-#define INITIAL_RESYNC_DELAY 50         /* Delay before first resync. */
+#define INITIAL_RESYNC_DELAY 50                /* Delay before first resync. */
 #endif
 
      static const int moff[12] =
@@ -470,30 +470,30 @@ Also note h<cr> command which starts a resync to MSF signal.
 /* Flags for a raw open() of the clock serial device. */
 #ifdef O_NOCTTY /* Good, we can avoid tty becoming controlling tty. */
 #define OPEN_FLAGS (O_RDWR | O_NOCTTY)
-#else           /* Oh well, it may not matter... */
+#else          /* Oh well, it may not matter... */
 #define OPEN_FLAGS (O_RDWR)
 #endif
 
 
 /* Length of queue of command bytes to be sent. */
-#define CMDQUEUELEN 4                   /* Enough for two cmds + each \r. */
+#define CMDQUEUELEN 4                  /* Enough for two cmds + each \r. */
 /* Queue tick time; interval in seconds between chars taken off queue. */
 /* Must be >= 2 to allow o\r response to come back uninterrupted. */
-#define QUEUETICK   2                   /* Allow o\r reply to finish. */
+#define QUEUETICK   2                  /* Allow o\r reply to finish. */
 
 /*
  * ARC unit control structure
  */
 struct arcunit {
-       l_fp lastrec;       /* Time tag for the receive time (system). */
-       int status;         /* Clock status. */
+       l_fp lastrec;       /* Time tag for the receive time (system). */
+       int status;         /* Clock status. */
 
-       int quality;        /* Quality of reception 0--5 for unit. */
+       int quality;        /* Quality of reception 0--5 for unit. */
        /* We may also use the values -1 or 6 internally. */
        u_long quality_stamp; /* Next time to reset quality average. */
 
        u_long next_resync; /* Next resync time (s) compared to current_time. */
-       int resyncing;      /* Resync in progress if true. */
+       int resyncing;      /* Resync in progress if true. */
 
        /* In the outgoing queue, cmdqueue[0] is next to be sent. */
        char cmdqueue[CMDQUEUELEN+1]; /* Queue of outgoing commands + \0. */
@@ -531,7 +531,7 @@ static void dummy_event_handler (struct peer *);
 static void   arc_event_handler (struct peer *);
 #endif /* 0 */
 
-#define QUALITY_UNKNOWN     -1 /* Indicates unknown clock quality. */
+#define QUALITY_UNKNOWN            -1 /* Indicates unknown clock quality. */
 #define MIN_CLOCK_QUALITY    0 /* Min quality clock will return. */
 #define MIN_CLOCK_QUALITY_OK 3 /* Min quality for OK reception. */
 #define MAX_CLOCK_QUALITY    5 /* Max quality clock will return. */
@@ -539,22 +539,22 @@ static void   arc_event_handler (struct peer *);
 /*
  * Function prototypes
  */
-static  int     arc_start       (int, struct peer *);
-static  void    arc_shutdown    (int, struct peer *);
-static  void    arc_receive     (struct recvbuf *);
-static  void    arc_poll        (int, struct peer *);
+static int     arc_start       (int, struct peer *);
+static void    arc_shutdown    (int, struct peer *);
+static void    arc_receive     (struct recvbuf *);
+static void    arc_poll        (int, struct peer *);
 
 /*
  * Transfer vector
  */
 struct  refclock refclock_arc = {
-       arc_start,              /* start up driver */
-       arc_shutdown,           /* shut down driver */
-       arc_poll,               /* transmit poll message */
-       noentry,                /* not used (old arc_control) */
-       noentry,                /* initialize driver (not used) */
-       noentry,                /* not used (old arc_buginfo) */
-       NOFLAGS                 /* not used */
+       arc_start,              /* start up driver */
+       arc_shutdown,           /* shut down driver */
+       arc_poll,               /* transmit poll message */
+       noentry,                /* not used (old arc_control) */
+       noentry,                /* initialize driver (not used) */
+       noentry,                /* not used (old arc_buginfo) */
+       NOFLAGS                 /* not used */
 };
 
 /* Queue us up for the next tick. */
@@ -814,9 +814,9 @@ send_slow(
        if(spaceleft < sl) { /* Should not normally happen... */
 #ifdef DEBUG
                msyslog(LOG_NOTICE, "ARCRON: send-buffer overrun (%d/%d)",
-                      sl, spaceleft);
+                       sl, spaceleft);
 #endif
-               return(0);                      /* FAILED! */
+               return(0);                      /* FAILED! */
        }
 
        /* Copy in the command to be sent. */
@@ -848,10 +848,10 @@ get1(char *p, int *val)
  (((q) < MIN_CLOCK_QUALITY_OK) ? "TOO POOR, will not use clock" : \
   "OK, will use clock"))
 
-     /*
+/*
  * arc_receive - receive data from the serial interface
  */
-     static void
+static void
 arc_receive(
        struct recvbuf *rbufp
        )
@@ -1007,7 +1007,7 @@ arc_receive(
        /* Just in case we still have lots of rubbish in the buffer... */
        /* ...and to avoid the same timestamp being reused by mistake, */
        /* eg on receipt of the \r coming in on its own after the      */
-       /* timecode.                                                   */
+       /* timecode.                                                   */
        if(pp->lencode >= LENARC) {
 #ifdef DEBUG
                if(debug && (rbufp->recv_buffer[0] != '\r'))
@@ -1085,9 +1085,9 @@ arc_receive(
                        }
 #endif
                        msyslog(LOG_NOTICE,
-                              "ARCRON: sync finished, signal quality %d: %s",
-                              up->quality,
-                              quality_action(up->quality));
+                               "ARCRON: sync finished, signal quality %d: %s",
+                               up->quality,
+                               quality_action(up->quality));
                        up->resyncing = 0; /* Resync is over. */
                        quality_average = 0;
                        quality_sum = 0;
@@ -1212,7 +1212,7 @@ arc_receive(
        if(pp->year >= YEAR_PIVOT+2000-2 ) {                    /* Y2KFixes */
                /*This should get attention B^> */
                msyslog(LOG_NOTICE,
-                      "ARCRON: fix me!  EITHER YOUR DATE IS BADLY WRONG or else I will break soon!");
+                       "ARCRON: fix me!  EITHER YOUR DATE IS BADLY WRONG or else I will break soon!");
        }
 #ifdef DEBUG
        if(debug) {
@@ -1273,50 +1273,52 @@ arc_receive(
        if(peer->MODE > 0) {
                if(pp->sloppyclockflag & CLK_FLAG1) {
                        struct tm  local;
-                       struct tm *gmtp;
-                       time_t     unixtime;
+                       struct tm *gmtp;
+                       time_t     unixtime;
 
-                       /*
-                        * Convert to GMT for sites that distribute localtime.
+                       /*
+                        * Convert to GMT for sites that distribute localtime.
                         * This means we have to do Y2K conversion on the
                         * 2-digit year; otherwise, we get the time wrong.
-                        */
-          
+                        */
+
+                       memset(&local, 0, sizeof(local));
+
                        local.tm_year  = pp->year-1900;
-                       local.tm_mon   = month-1;
-                       local.tm_mday  = pp->day;
-                       local.tm_hour  = pp->hour;
-                       local.tm_min   = pp->minute;
-                       local.tm_sec   = pp->second;
-                       switch (peer->MODE) {
+                       local.tm_mon   = month-1;
+                       local.tm_mday  = pp->day;
+                       local.tm_hour  = pp->hour;
+                       local.tm_min   = pp->minute;
+                       local.tm_sec   = pp->second;
+                       switch (peer->MODE) {
                            case 1:
                                local.tm_isdst = (flags & 2);
                                break;
                            case 2:
-                               local.tm_isdst = (flags & 2);
+                               local.tm_isdst = (flags & 2);
                                break;
                            case 3:
                                switch (flags & 3) {
                                    case 0: /* It is unclear exactly when the 
-                                              Arcron changes from DST->ST and 
+                                              Arcron changes from DST->ST and 
                                               ST->DST. Testing has shown this
                                               to be irregular. For the time 
                                               being, let the OS decide. */
-                                       local.tm_isdst = 0;
+                                       local.tm_isdst = 0;
 #ifdef DEBUG
                                        if (debug)
                                            printf ("arc: DST = 00 (0)\n"); 
 #endif
                                        break;
                                    case 1: /* dst->st time */
-                                       local.tm_isdst = -1;
+                                       local.tm_isdst = -1;
 #ifdef DEBUG
                                        if (debug) 
                                            printf ("arc: DST = 01 (1)\n"); 
 #endif
                                        break;
                                    case 2: /* st->dst time */
-                                       local.tm_isdst = -1;
+                                       local.tm_isdst = -1;
 #ifdef DEBUG
                                        if (debug) 
                                            printf ("arc: DST = 10 (2)\n"); 
@@ -1333,26 +1335,26 @@ arc_receive(
                                break;
                            default:
                                msyslog(LOG_NOTICE, "ARCRON: Invalid mode %d",
-                                       peer->MODE);
+                                       peer->MODE);
                                return;
                                break;
                        }
-                       unixtime = mktime (&local);
-                       if ((gmtp = gmtime (&unixtime)) == NULL)
-                       {
+                       unixtime = mktime (&local);
+                       if ((gmtp = gmtime (&unixtime)) == NULL)
+                       {
                                pp->lencode = 0;
-                               refclock_report (peer, CEVNT_FAULT);
-                               return;
-                       }
+                               refclock_report (peer, CEVNT_FAULT);
+                               return;
+                       }
                        pp->year = gmtp->tm_year+1900;
-                       month = gmtp->tm_mon+1;
-                       pp->day = ymd2yd(pp->year,month,gmtp->tm_mday);
-                       /* pp->day = gmtp->tm_yday; */
-                       pp->hour = gmtp->tm_hour;
-                       pp->minute = gmtp->tm_min;
-                       pp->second = gmtp->tm_sec;
+                       month = gmtp->tm_mon+1;
+                       pp->day = ymd2yd(pp->year,month,gmtp->tm_mday);
+                       /* pp->day = gmtp->tm_yday; */
+                       pp->hour = gmtp->tm_hour;
+                       pp->minute = gmtp->tm_min;
+                       pp->second = gmtp->tm_sec;
 #ifdef DEBUG
-                       if (debug)
+                       if (debug)
                        {
                                printf ("arc: time is %04d/%02d/%02d %02d:%02d:%02d UTC\n",
                                        pp->year,month,gmtp->tm_mday,pp->hour,pp->minute,
@@ -1361,10 +1363,10 @@ arc_receive(
 #endif
                } else 
                {
-                       /*
-                       * For more rational sites distributing UTC
-                       */
-                       pp->day    = ymd2yd(pp->year,month,pp->day);
+                       /*
+                       * For more rational sites distributing UTC
+                       */
+                       pp->day    = ymd2yd(pp->year,month,pp->day);
                }
        }
 
@@ -1393,10 +1395,10 @@ arc_receive(
        if(up->saved_flags != pp->sloppyclockflag) {
 #ifdef DEBUG
                msyslog(LOG_NOTICE, "ARCRON: flags enabled: %s%s%s%s",
-                      ((pp->sloppyclockflag & CLK_FLAG1) ? "1" : "."),
-                      ((pp->sloppyclockflag & CLK_FLAG2) ? "2" : "."),
-                      ((pp->sloppyclockflag & CLK_FLAG3) ? "3" : "."),
-                      ((pp->sloppyclockflag & CLK_FLAG4) ? "4" : "."));
+                       ((pp->sloppyclockflag & CLK_FLAG1) ? "1" : "."),
+                       ((pp->sloppyclockflag & CLK_FLAG2) ? "2" : "."),
+                       ((pp->sloppyclockflag & CLK_FLAG3) ? "3" : "."),
+                       ((pp->sloppyclockflag & CLK_FLAG4) ? "4" : "."));
                /* Note effects of flags changing... */
                if(debug) {
                        printf("arc: PRECISION = %d.\n", peer->precision);
index 245f68fadf35b4d3624da3d67fec889163266590..d7dace0582a53320c30bf21ea97e87b950c9c11e 100644 (file)
@@ -240,6 +240,8 @@ chronolog_receive(
             * otherwise, we get the time wrong.
             */
            
+           memset(&local, 0, sizeof(local));
+
            local.tm_year  = up->year;
            local.tm_mon   = up->month-1;
            local.tm_mday  = up->day;
index 6a6e8c60324dc7de8b4cc0664ae3487f0d65dc2f..e3fcdcd769565c29d9e40a27152d3feafb405049 100644 (file)
@@ -292,6 +292,8 @@ datum_pts_start(
 
 #ifdef HAVE_TERMIOS
 
+       memset(&arg, 0, sizeof(arg));
+
        arg.c_iflag = IGNBRK;
        arg.c_oflag = 0;
        arg.c_cflag = B9600 | CS8 | CREAD | PARENB | CLOCAL;
index e0ab669ed0e990ad36ce8486385f115e5182c415..d85849eac5b7a6d076fad75bc2322094d4ef302b 100644 (file)
@@ -35,7 +35,7 @@ extern int async_write(int, const void *, unsigned int);
  *
  * Input format:
  *
- *      hh:mm:ss   <cr>
+ *     hh:mm:ss   <cr>
  *
  * hh:mm:ss -- what you'd expect, with a 24 hour clock.  (Heck, that's the only
  * way it could get stupider.)  We take time on the <cr>.
@@ -64,11 +64,11 @@ extern int async_write(int, const void *, unsigned int);
  * Dumb clock control structure
  */
 struct dumbclock_unit {
-       u_char    tcswitch;                  /* timecode switch */
-       l_fp      laststamp;                 /* last receive timestamp */
-       u_char    lasthour;                  /* last hour (for monitor) */
-       u_char    linect;                    /* count ignored lines (for monitor */
-        struct tm ymd;                      /* struct tm for y/m/d only */
+       u_char    tcswitch;     /* timecode switch */
+       l_fp      laststamp;    /* last receive timestamp */
+       u_char    lasthour;     /* last hour (for monitor) */
+       u_char    linect;       /* count ignored lines (for monitor */
+       struct tm ymd;          /* struct tm for y/m/d only */
 };
 
 /*
@@ -128,10 +128,6 @@ dumbclock_start(
         * Allocate and initialize unit structure
         */
        up = (struct dumbclock_unit *)emalloc(sizeof(struct dumbclock_unit));
-       if (up == NULL) {
-               (void) close(fd);
-               return (0);
-       }
        memset((char *)up, 0, sizeof(struct dumbclock_unit));
        pp = peer->procptr;
        pp->unitptr = (caddr_t)up;
@@ -153,14 +149,10 @@ dumbclock_start(
        tm_time_p = gmtime(&now);
 #endif
        if (tm_time_p)
-       {
-           up->ymd = *tm_time_p;
-       }
+               up->ymd = *tm_time_p;
        else
-       {
-           return 0;
-       }
-           
+               return 0;
+
        /*
         * Initialize miscellaneous variables
         */
@@ -202,12 +194,12 @@ dumbclock_receive(
        struct refclockproc *pp;
        struct peer *peer;
 
-       l_fp         trtmp;     /* arrival timestamp */
-       int          hours;     /* hour-of-day */
-       int          minutes;   /* minutes-past-the-hour */
-       int          seconds;   /* seconds */
-       int          temp;      /* int temp */
-       int          got_good;  /* got a good time flag */
+       l_fp    trtmp;          /* arrival timestamp */
+       int     hours;          /* hour-of-day */
+       int     minutes;        /* minutes-past-the-hour */
+       int     seconds;        /* seconds */
+       int     temp;           /* int temp */
+       int     got_good;       /* got a good time flag */
 
        /*
         * Initialize pointers and read the timecode and timestamp
@@ -222,7 +214,7 @@ dumbclock_receive(
                        up->tcswitch = 1;
                        up->laststamp = trtmp;
                } else
-                   up->tcswitch = 0;
+                       up->tcswitch = 0;
                return;
        }
        pp->lencode = (u_short)temp;
@@ -255,10 +247,12 @@ dumbclock_receive(
 
            /*
             * Convert to GMT for sites that distribute localtime.  This
-             * means we have to figure out what day it is.  Easier said
+            * means we have to figure out what day it is.  Easier said
             * than done...
             */
 
+           memset(&asserted_tm, 0, sizeof(asserted_tm));
+
            asserted_tm.tm_year  = up->ymd.tm_year;
            asserted_tm.tm_mon   = up->ymd.tm_mon;
            asserted_tm.tm_mday  = up->ymd.tm_mday;
@@ -383,4 +377,4 @@ dumbclock_poll(
 
 #else
 int refclock_dumbclock_bs;
-#endif /* REFCLOCK */
+#endif /* defined(REFCLOCK) && defined(CLOCK_DUMBCLOCK) */
index 10fc6500513fa716c34a792abf3bcd0828baba6b..6f7d58e5779c2153b7bdebbe207050b74988ce51 100644 (file)
@@ -144,6 +144,8 @@ pcf_poll(
                return;
        }
 
+       memset(&tm, 0, sizeof(tm));
+
        tm.tm_mday = buf[11] * 10 + buf[10];
        tm.tm_mon = buf[13] * 10 + buf[12] - 1;
        tm.tm_year = buf[15] * 10 + buf[14];
index 4ec45469a9c36ae133fdadda0fea8e13bf3da038..e4b99599d990c496a89e693107d7cfdc01370db2 100644 (file)
@@ -298,7 +298,8 @@ char *NTstrerror(int errnum);
 # define HAVE_TIMEPPS_H
 # define HAVE_PPSAPI
 # define CLOCK_ATOM
-/* # define CLOCK_DUMBCLOCK */ /* refclock_dumbclock.c needs work to open COMx: */
+# define CLOCK_CHRONOLOG
+# define CLOCK_DUMBCLOCK
 # define CLOCK_HOPF_SERIAL     /* device 38, hopf DCF77/GPS serial line receiver  */
 # define CLOCK_HOPF_PCI                /* device 39, hopf DCF77/GPS PCI-Bus receiver  */
 # define CLOCK_JUPITER
index b7ea2545b802ddaa0c011c382872f269eca682c1..3003f6d71980ebfdba7b4d4f5bceb804f941e849 100644 (file)
@@ -535,6 +535,10 @@ SOURCE=..\..\..\ntpd\refclock_conf.c
 # End Source File
 # Begin Source File
 
+SOURCE=..\..\..\ntpd\refclock_chronolog.c
+# End Source File
+# Begin Source File
+
 SOURCE=..\..\..\ntpd\refclock_datum.c
 # PROP Exclude_From_Build 1
 # End Source File
index 2ad114e4aa8754c1871d868f8d013d6bad04a6c6..45df9571c665986a05fc00ce9b8575a9f02111ef 100644 (file)
                                        />
                                </FileConfiguration>
                        </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\refclock_chronolog.c"
+                               >
+                       </File>
                        <File
                                RelativePath="..\..\..\ntpd\refclock_chu.c"
                                >
index 0cc4f03785e7e0901cbf6c2763cfbd989edfe7c4..e40294ec89761cb2394f739d6bf7f5c05558c562 100644 (file)
@@ -1073,6 +1073,8 @@ C library not to trash the stack on bad numbers! */
 /* Clearing the save file is similar. */
 
     } else if (operation == save_clear) {
+       memset(&buffer, 0, sizeof(buffer));
+
         if (fseek(savefile,0l,SEEK_SET) != 0 ||
                 fwrite(&buffer,sizeof(buffer),1,savefile) != 1 ||
                 fflush(savefile) != 0 || ferror(savefile))