Paranoia: zero COMPAT_30 ntptimeval and 32-bit ntptimeval too.

These structs don't have padding but safer to keep the code
structured the same way between the various ntp_gettimes in case
anyone makes more copypasta of it for future updates.
This commit is contained in:
riastradh 2018-10-30 14:43:38 +00:00
parent cc8a85962e
commit 1c1a78241c
2 changed files with 8 additions and 4 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_time_30.c,v 1.5 2016/11/03 03:37:06 riastradh Exp $ */
/* $NetBSD: kern_time_30.c,v 1.6 2018/10/30 14:43:38 riastradh Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@ -36,7 +36,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_time_30.c,v 1.5 2016/11/03 03:37:06 riastradh Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_time_30.c,v 1.6 2018/10/30 14:43:38 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_ntp.h"
@ -68,6 +68,7 @@ compat_30_sys_ntp_gettime(struct lwp *l,
if (SCARG(uap, ntvp)) {
ntp_gettime(&ntv);
memset(&ntv30, 0, sizeof(ntv30));
TIMESPEC_TO_TIMEVAL(&tv, &ntv.time);
timeval_to_timeval50(&tv, &ntv30.time);
ntv30.maxerror = ntv.maxerror;

View File

@ -1,4 +1,4 @@
/* $NetBSD: netbsd32_time.c,v 1.49 2017/02/26 10:26:19 njoly Exp $ */
/* $NetBSD: netbsd32_time.c,v 1.50 2018/10/30 14:43:38 riastradh Exp $ */
/*
* Copyright (c) 1998, 2001 Matthew R. Green
@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: netbsd32_time.c,v 1.49 2017/02/26 10:26:19 njoly Exp $");
__KERNEL_RCSID(0, "$NetBSD: netbsd32_time.c,v 1.50 2018/10/30 14:43:38 riastradh Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ntp.h"
@ -66,6 +66,7 @@ netbsd32___ntp_gettime50(struct lwp *l,
if (SCARG_P32(uap, ntvp)) {
ntp_gettime(&ntv);
memset(&ntv32, 0, sizeof(ntv32));
ntv32.time.tv_sec = ntv.time.tv_sec;
ntv32.time.tv_nsec = ntv.time.tv_nsec;
ntv32.maxerror = (netbsd32_long)ntv.maxerror;
@ -96,6 +97,7 @@ compat_50_netbsd32_ntp_gettime(struct lwp *l,
if (SCARG_P32(uap, ntvp)) {
ntp_gettime(&ntv);
memset(&ntv32, 0, sizeof(ntv32));
ntv32.time.tv_sec = (int32_t)ntv.time.tv_sec;
ntv32.time.tv_nsec = ntv.time.tv_nsec;
ntv32.maxerror = (netbsd32_long)ntv.maxerror;
@ -126,6 +128,7 @@ compat_30_netbsd32_ntp_gettime(struct lwp *l, const struct compat_30_netbsd32_nt
if (SCARG_P32(uap, ntvp)) {
ntp_gettime(&ntv);
memset(&ntv32, 0, sizeof(ntv32));
ntv32.time.tv_sec = ntv.time.tv_sec;
ntv32.time.tv_usec = ntv.time.tv_nsec / 1000;
ntv32.maxerror = (netbsd32_long)ntv.maxerror;