diff options
author | cy <cy@FreeBSD.org> | 2015-05-04 04:45:59 +0000 |
---|---|---|
committer | cy <cy@FreeBSD.org> | 2015-05-04 04:45:59 +0000 |
commit | 1818eba70c74c4ba7173ef82fd98d197914adc74 (patch) | |
tree | 62ff96a32b854c652d9d65280d1d6fd2089b2f1e /contrib/ntp/parseutil | |
parent | 46cb5cb412522de16502b815c1126a1bf652045b (diff) | |
parent | f63afe28012870b3eb07e80844160966b32ef52e (diff) | |
download | FreeBSD-src-1818eba70c74c4ba7173ef82fd98d197914adc74.zip FreeBSD-src-1818eba70c74c4ba7173ef82fd98d197914adc74.tar.gz |
MFV ntp 4.2.8p2 (r281348)
Reviewed by: delphij (suggested MFC)
Approved by: roberto
Security: CVE-2015-1798, CVE-2015-1799
Security: VuXML ebd84c96-dd7e-11e4-854e-3c970e169bc2
MFC after: 1 month
Diffstat (limited to 'contrib/ntp/parseutil')
-rw-r--r-- | contrib/ntp/parseutil/Makefile.in | 10 | ||||
-rw-r--r-- | contrib/ntp/parseutil/dcfd.c | 62 | ||||
-rw-r--r-- | contrib/ntp/parseutil/testdcf.c | 25 |
3 files changed, 56 insertions, 41 deletions
diff --git a/contrib/ntp/parseutil/Makefile.in b/contrib/ntp/parseutil/Makefile.in index e741a93..999f4f1 100644 --- a/contrib/ntp/parseutil/Makefile.in +++ b/contrib/ntp/parseutil/Makefile.in @@ -41,8 +41,7 @@ subdir = parseutil ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \ $(top_srcdir)/sntp/libopts/m4/stdnoreturn.m4 \ - $(top_srcdir)/sntp/libevent/m4/openldap-thread-check.m4 \ - $(top_srcdir)/sntp/libevent/m4/openldap.m4 \ + $(top_srcdir)/sntp/m4/ax_c99_struct_init.m4 \ $(top_srcdir)/sntp/m4/define_dir.m4 \ $(top_srcdir)/sntp/m4/hms_search_lib.m4 \ $(top_srcdir)/sntp/m4/libtool.m4 \ @@ -71,6 +70,8 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \ $(top_srcdir)/sntp/m4/ntp_sntp.m4 \ $(top_srcdir)/sntp/m4/ntp_ver_suffix.m4 \ $(top_srcdir)/sntp/m4/ntp_vpathhack.m4 \ + $(top_srcdir)/sntp/m4/openldap-thread-check.m4 \ + $(top_srcdir)/sntp/m4/openldap.m4 \ $(top_srcdir)/sntp/m4/os_cflags.m4 \ $(top_srcdir)/sntp/m4/snprintf.m4 \ $(top_srcdir)/sntp/m4/version.m4 $(top_srcdir)/configure.ac @@ -324,6 +325,11 @@ TIMETRIM_DL = @TIMETRIM_DL@ TIMETRIM_DS = @TIMETRIM_DS@ TIMETRIM_MS = @TIMETRIM_MS@ TIMETRIM_NI = @TIMETRIM_NI@ +UPDATE_LEAP_DB = @UPDATE_LEAP_DB@ +UPDATE_LEAP_DL = @UPDATE_LEAP_DL@ +UPDATE_LEAP_DS = @UPDATE_LEAP_DS@ +UPDATE_LEAP_MS = @UPDATE_LEAP_MS@ +UPDATE_LEAP_NI = @UPDATE_LEAP_NI@ VERSION = @VERSION@ VER_SUFFIX = @VER_SUFFIX@ YACC = @YACC@ diff --git a/contrib/ntp/parseutil/dcfd.c b/contrib/ntp/parseutil/dcfd.c index 0db94c0..652b375 100644 --- a/contrib/ntp/parseutil/dcfd.c +++ b/contrib/ntp/parseutil/dcfd.c @@ -1,6 +1,6 @@ /* * /src/NTP/REPOSITORY/ntp4-dev/parseutil/dcfd.c,v 4.18 2005/10/07 22:08:18 kardel RELEASE_20051008_A - * + * * dcfd.c,v 4.18 2005/10/07 22:08:18 kardel RELEASE_20051008_A * * DCF77 100/200ms pulse synchronisation daemon program (via 50Baud serial line) @@ -14,7 +14,7 @@ * Leap second handling (at that level you should switch to NTP Version 4 - really!) * * Copyright (c) 1995-2005 by Frank Kardel <kardel <AT> ntp.org> - * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universität Erlangen-Nürnberg, Germany + * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universitaet Erlangen-Nuernberg, Germany * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -198,7 +198,7 @@ static char skip_adjust = 1; /* discard first adjustment (bad samples) */ #define DCFB_ANNOUNCE 0x0001 /* switch time zone warning (DST switch) */ #define DCFB_DST 0x0002 /* DST in effect */ #define DCFB_LEAP 0x0004 /* LEAP warning (1 hour prior to occurrence) */ -#define DCFB_ALTERNATE 0x0008 /* alternate antenna used */ +#define DCFB_CALLBIT 0x0008 /* "call bit" used to signalize irregularities in the control facilities */ struct clocktime /* clock time broken up from time code */ { @@ -219,9 +219,16 @@ typedef struct clocktime clocktime_t; /* * (usually) quick constant multiplications */ +#ifndef TIMES10 #define TIMES10(_X_) (((_X_) << 3) + ((_X_) << 1)) /* *8 + *2 */ +#endif +#ifndef TIMES24 #define TIMES24(_X_) (((_X_) << 4) + ((_X_) << 3)) /* *16 + *8 */ +#endif +#ifndef TIMES60 #define TIMES60(_X_) ((((_X_) << 4) - (_X_)) << 2) /* *(16 - 1) *4 */ +#endif + /* * generic l_abs() function */ @@ -260,7 +267,8 @@ typedef struct clocktime clocktime_t; * Second Contents * 0 - 10 AM: free, FM: 0 * 11 - 14 free - * 15 R - alternate antenna + * 15 R - "call bit" used to signalize irregularities in the control facilities + * (until 2003 indicated transmission via alternate antenna) * 16 A1 - expect zone change (1 hour before) * 17 - 18 Z1,Z2 - time zone * 0 0 illegal @@ -294,7 +302,7 @@ typedef struct clocktime clocktime_t; * while the length is given as the difference between the start index and * the start index of the following field. */ -static struct rawdcfcode +static struct rawdcfcode { char offset; /* start bit */ } rawdcfcode[] = @@ -361,7 +369,7 @@ static struct dcfparam { unsigned char onebits[60]; unsigned char zerobits[60]; -} dcfparam = +} dcfparam = { "###############RADMLS1248124P124812P1248121241248112481248P", /* 'ONE' representation */ "--------------------s-------p------p----------------------p" /* 'ZERO' representation */ @@ -384,7 +392,7 @@ ext_bf( register int i, first; first = rawdcfcode[idx].offset; - + for (i = rawdcfcode[idx+1].offset - 1; i >= first; i--) { sum <<= 1; @@ -438,7 +446,7 @@ convert_rawdcf( PRINTF("%-30s", "*** INCOMPLETE"); return CVT_NONE; } - + /* * check Start and Parity bits */ @@ -495,7 +503,7 @@ convert_rawdcf( clock_time->flags |= DCFB_LEAP; if (ext_bf(buffer, DCF_R)) - clock_time->flags |= DCFB_ALTERNATE; + clock_time->flags |= DCFB_CALLBIT; return CVT_OK; } @@ -739,7 +747,7 @@ cvt_rawdcf( * if everything went well so far return the result of the symbolic * conversion routine else just the accumulated errors */ - if (rtc != CVT_NONE) + if (rtc != CVT_NONE) { PRINTF("%-30s", "*** BAD DATA"); } @@ -758,13 +766,13 @@ dcf_to_unixtime( ) { #define SETRTC(_X_) { if (cvtrtc) *cvtrtc = (_X_); } - static int days_of_month[] = + static int days_of_month[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; register int i; time_t t; - + /* * map 2 digit years to 19xx (DCF77 is a 20th century item) */ @@ -847,7 +855,7 @@ dcf_to_unixtime( */ t = TIMES60(t) + clock_time->minute; /* sec */ - + /* * calculate UTC in minutes */ @@ -1247,7 +1255,7 @@ usage( */ static int check_y2k( void ) -{ +{ int year; /* current working year */ int year0 = 1900; /* sarting year for NTP time */ int yearend; /* ending year we test for NTP time. @@ -1306,7 +1314,7 @@ check_y2k( void ) * *a minor difference to arg2 type */ if ( ct.year != year ) { - fprintf( stdout, + fprintf( stdout, "%04d: dcf_to_unixtime(,%d) CORRUPTED ct.year: was %d\n", (int)year, (int)Flag, (int)ct.year ); Error(year); @@ -1316,9 +1324,9 @@ check_y2k( void ) Expected = t * 24 * 60 * 60; if ( Observed != Expected || Flag ) { /* time difference */ - fprintf( stdout, + fprintf( stdout, "%04d: dcf_to_unixtime(,%d) FAILURE: was=%lu s/b=%lu (%ld)\n", - year, (int)Flag, + year, (int)Flag, (unsigned long)Observed, (unsigned long)Expected, ((long)Observed - (long)Expected) ); Error(year); @@ -1344,7 +1352,7 @@ rawdcf_init( * Here a voltage between the DTR and the RTS line is used. Unfortunately * the name has changed from CIOCM_DTR to TIOCM_DTR recently. */ - + #ifdef TIOCM_DTR int sl232 = TIOCM_DTR; /* turn on DTR for power supply */ #else @@ -1438,7 +1446,7 @@ main( errs=1; } break; - + case 'd': if (ac > 1) { @@ -1451,8 +1459,8 @@ main( errs=1; } break; - - case 'Y': + + case 'Y': errs=check_y2k(); exit( errs ? 1 : 0 ); @@ -1519,7 +1527,7 @@ main( unsigned int rtc = CVT_NONE; rawdcf_init(fd); - + timeout.tv_sec = 1; timeout.tv_usec = 500000; @@ -1560,7 +1568,7 @@ main( */ if (!interactive) detach(); - + /* * get syslog() initialized */ @@ -1618,7 +1626,7 @@ main( it.it_interval.tv_usec = 0; it.it_value.tv_sec = 1<<ADJINTERVAL; it.it_value.tv_usec = 0; - + if (setitimer(ITIMER_REAL, &it, (struct itimerval *)0) == -1) { syslog(LOG_ERR, "setitimer: %m"); @@ -1797,7 +1805,7 @@ main( wday[clock_time.wday], clock_time.hour, clock_time.minute, i, clock_time.day, clock_time.month, clock_time.year, - (clock_time.flags & DCFB_ALTERNATE) ? "R" : "_", + (clock_time.flags & DCFB_CALLBIT) ? "R" : "_", (clock_time.flags & DCFB_ANNOUNCE) ? "A" : "_", (clock_time.flags & DCFB_DST) ? "D" : "_", (clock_time.flags & DCFB_LEAP) ? "L" : "_", @@ -1829,7 +1837,7 @@ main( fflush(stdout); } } while ((rrc == -1) && (errno == EINTR)); - + /* * lost IO - sorry guys */ @@ -1839,7 +1847,7 @@ main( } closelog(); - + return 0; } diff --git a/contrib/ntp/parseutil/testdcf.c b/contrib/ntp/parseutil/testdcf.c index c78c242..00bf059 100644 --- a/contrib/ntp/parseutil/testdcf.c +++ b/contrib/ntp/parseutil/testdcf.c @@ -2,11 +2,11 @@ * /src/NTP/ntp4-dev/parseutil/testdcf.c,v 4.10 2005/08/06 14:18:43 kardel RELEASE_20050806_A * * testdcf.c,v 4.10 2005/08/06 14:18:43 kardel RELEASE_20050806_A - * + * * simple DCF77 100/200ms pulse test program (via 50Baud serial line) * * Copyright (c) 1995-2005 by Frank Kardel <kardel <AT> ntp.org> - * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universität Erlangen-Nürnberg, Germany + * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universitaet Erlangen-Nuernberg, Germany * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -46,10 +46,10 @@ /* * state flags */ -#define DCFB_ANNOUNCE 0x0001 /* switch time zone warning (DST switch) */ -#define DCFB_DST 0x0002 /* DST in effect */ -#define DCFB_LEAP 0x0004 /* LEAP warning (1 hour prior to occurrence) */ -#define DCFB_ALTERNATE 0x0008 /* alternate antenna used */ +#define DCFB_ANNOUNCE 0x0001 /* switch time zone warning (DST switch) */ +#define DCFB_DST 0x0002 /* DST in effect */ +#define DCFB_LEAP 0x0004 /* LEAP warning (1 hour prior to occurrence) */ +#define DCFB_CALLBIT 0x0008 /* "call bit" used to signalize irregularities in the control facilities */ struct clocktime /* clock time broken up from time code */ { @@ -102,7 +102,8 @@ static char type(unsigned int); * Second Contents * 0 - 10 AM: free, FM: 0 * 11 - 14 free - * 15 R - alternate antenna + * 15 R - "call bit" used to signalize irregularities in the control facilities + * (until 2003 indicated transmission via alternate antenna) * 16 A1 - expect zone change (1 hour before) * 17 - 18 Z1,Z2 - time zone * 0 0 illegal @@ -130,7 +131,7 @@ static char type(unsigned int); static char revision[] = "4.10"; -static struct rawdcfcode +static struct rawdcfcode { char offset; /* start bit */ } rawdcfcode[] = @@ -185,7 +186,7 @@ ext_bf( register int i, first; first = rawdcfcode[idx].offset; - + for (i = rawdcfcode[idx+1].offset - 1; i >= first; i--) { sum <<= 1; @@ -223,7 +224,7 @@ convert_rawdcf( printf("%-30s", "*** INCOMPLETE"); return CVT_NONE; } - + /* * check Start and Parity bits */ @@ -274,7 +275,7 @@ convert_rawdcf( clock_time->flags |= DCFB_LEAP; if (ext_bf(buffer, DCF_R)) - clock_time->flags |= DCFB_ALTERNATE; + clock_time->flags |= DCFB_CALLBIT; return CVT_OK; } @@ -490,7 +491,7 @@ main( wday[clock_time.wday], (int)clock_time.hour, (int)clock_time.minute, (int)i, (int)clock_time.day, (int)clock_time.month, (int)clock_time.year, - (clock_time.flags & DCFB_ALTERNATE) ? "R" : "_", + (clock_time.flags & DCFB_CALLBIT) ? "R" : "_", (clock_time.flags & DCFB_ANNOUNCE) ? "A" : "_", (clock_time.flags & DCFB_DST) ? "D" : "_", (clock_time.flags & DCFB_LEAP) ? "L" : "_" |