Sunday, September 27, 2020

Re: net/ntp: fix for negative adjtv.tv_usec

ok cheloha@

you need a ports person to sign off too,
though.

> On Sep 27, 2020, at 07:43, Matthieu Herrb <matthieu@herrb.eu> wrote:
>
> On Sat, Sep 26, 2020 at 04:03:56PM -0500, Scott Cheloha wrote:
>> traveling and on phone, sorry for formatting.
>>
>> that looks correct.
>>
>> there is an identical problem in the ntpdate
>> code elsewhere in the net/ntp port. you
>> could fix them both in the same patch, the
>> fix should be the same.
>>
>
> You're right. Updated patch :
>
> Index: Makefile
> ===================================================================
> RCS file: /cvs/OpenBSD/ports/net/ntp/Makefile,v
> retrieving revision 1.80
> diff -u -p -u -r1.80 Makefile
> --- Makefile 20 Mar 2020 16:44:26 -0000 1.80
> +++ Makefile 26 Sep 2020 17:27:46 -0000
> @@ -7,7 +7,7 @@ COMMENT= Network Time Protocol reference
> # 'pl' for local use.
>
> VERSION= 4.2.8p10
> -REVISION= 5
> +REVISION= 6
> DISTNAME= ntp-${VERSION}
> PKGNAME= ntp-${VERSION:S/p/pl/}
> CATEGORIES= net
> Index: patches/patch-libntp_systime_c
> ===================================================================
> RCS file: patches/patch-libntp_systime_c
> diff -N patches/patch-libntp_systime_c
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-libntp_systime_c 27 Sep 2020 12:40:48 -0000
> @@ -0,0 +1,18 @@
> +$OpenBSD$
> +
> +Normalize adjtime() argument.
> +
> +Index: libntp/systime.c
> +--- libntp/systime.c.orig
> ++++ libntp/systime.c
> +@@ -346,6 +346,10 @@ adj_systime(
> + adjtv.tv_usec = -adjtv.tv_usec;
> + sys_residual = -sys_residual;
> + }
> ++ while (adjtv.tv_usec < 0) {
> ++ adjtv.tv_usec += 1000000;
> ++ adjtv.tv_sec -= 1;
> ++ }
> + if (adjtv.tv_sec != 0 || adjtv.tv_usec != 0) {
> + if (adjtime(&adjtv, &oadjtv) < 0) {
> + msyslog(LOG_ERR, "adj_systime: %m");
> Index: patches/patch-ntpdate_ntpdate_c
> ===================================================================
> RCS file: patches/patch-ntpdate_ntpdate_c
> diff -N patches/patch-ntpdate_ntpdate_c
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-ntpdate_ntpdate_c 27 Sep 2020 12:40:52 -0000
> @@ -0,0 +1,18 @@
> +$OpenBSD$
> +
> +Normalize adjtime() argument.
> +
> +Index: ntpdate/ntpdate.c
> +--- ntpdate/ntpdate.c.orig
> ++++ ntpdate/ntpdate.c
> +@@ -2041,6 +2041,10 @@ l_adj_systime(
> + adjtv.tv_usec = -adjtv.tv_usec;
> + }
> +
> ++ while (adjtv.tv_usec < 0) {
> ++ adjtv.tv_usec += 1000000;
> ++ adjtv.tv_sec -= 1;
> ++ }
> + if (adjtv.tv_usec != 0 && !debug) {
> + if (adjtime(&adjtv, &oadjtv) < 0) {
> + msyslog(LOG_ERR, "Can't adjust the time of day: %m");
>
> --
> Matthieu Herrb

No comments:

Post a Comment