]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 1643]: Range-check the decoding of the RIPE-NCC status codes
authorHarlan Stenn <stenn@ntp.org>
Sat, 25 Sep 2010 21:14:57 +0000 (21:14 +0000)
committerHarlan Stenn <stenn@ntp.org>
Sat, 25 Sep 2010 21:14:57 +0000 (21:14 +0000)
bk: 4c9e6651GDXN6_liakq50ewqFmUznQ

ChangeLog
ntpd/refclock_ripencc.c

index 24f2c9b102bf6a9f5329d29311605ddbc748d96c..e405a336c4872056f4ff92a084d231a0cbd37ba3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+---
+* [Bug 1643]: Range-check the decoding of the RIPE-NCC status codes.
+
 ---
 (4.2.6p3-RC2) 2010/09/25 Released by Harlan Stenn <stenn@ntp.org>
 
index 994cd0c7bd9313a6ffe06ffbc752890e81b966bc..94a1de46d0dc89b9fe72434e6c17b4fba9b0c664 100644 (file)
@@ -429,8 +429,8 @@ static      int     print_msg_table_header  (int rptcode, char *HdrStr, int force);
 static char *  show_time       (float time_of_week);
 
 /* RIPE NCC functions */
-static void    ripencc_control (int, struct refclockstat *, struct
-                               refclockstat *, struct peer *);
+static void    ripencc_control (int, const struct refclockstat *,
+                                struct refclockstat *, struct peer *);
 static int     ripencc_ppsapi  (struct peer *, int, int);
 static int     ripencc_get_pps_ts      (struct ripencc_unit *, l_fp *);
 static int     ripencc_start   (int, struct peer *);
@@ -615,7 +615,7 @@ ripencc_start(int unit, struct peer *peer)
 static void
 ripencc_control(
        int unit,               /* unit (not used) */
-       struct refclockstat *in, /* input parameters (not used) */
+       const struct refclockstat *in, /* input parameters (not used) */
        struct refclockstat *out, /* output parameters (not used) */
        struct peer *peer       /* peer structure pointer */
        )
@@ -3179,7 +3179,9 @@ static void rpt_rcvr_health (TSIPPKT *rpt)
 {
        unsigned char
                status1, status2;
-       static char
+       const char
+               *text;
+       static const char const
                *sc_text[] = {
                        "Doing position fixes",
                        "Don't have GPS time yet",
@@ -3203,8 +3205,11 @@ static void rpt_rcvr_health (TSIPPKT *rpt)
                return;
        }
 
+       text = (status1 < COUNTOF(sc_text))
+                  ? sc_text[status1]
+                  : "(out of range)";
        pbuf += sprintf(pbuf, "\nRcvr status1: %s (%02Xh); ",
-       sc_text[rpt->buf[0]], status1);
+               text, status1);
 
        pbuf += sprintf(pbuf, "status2: %s, %s (%02Xh)",
                (status2 & 0x01)?"No BBRAM":"BBRAM OK",
@@ -3382,7 +3387,7 @@ static void rpt_operating_parameters (TSIPPKT *rpt)
        pbuf += sprintf(pbuf, "\nOperating Parameters:");
        pbuf += sprintf(pbuf, "\n     Dynamics code = %d %s",
        dyn_code, dyn_text[dyn_code]);
-       pbuf += sprintf(pbuf, "\n     Elevation mask = %.2fΓΈ", el_mask * R2D);
+       pbuf += sprintf(pbuf, "\n     Elevation mask = %.2f?", el_mask * R2D);
        pbuf += sprintf(pbuf, "\n     SNR mask = %.2f", snr_mask);
        pbuf += sprintf(pbuf, "\n     DOP mask = %.2f", dop_mask);
        pbuf += sprintf(pbuf, "\n     DOP switch = %.2f", dop_switch);