From ec2dae81043709173aede70e71e4392b61dc8ff2 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Mon, 4 Jun 2018 20:00:41 -0600 Subject: [PATCH] Fix conversion of usec to nsec; from Scott Cheloha --- plugins/sudoers/starttime.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/plugins/sudoers/starttime.c b/plugins/sudoers/starttime.c index 277548c89..d5df0ffd7 100644 --- a/plugins/sudoers/starttime.c +++ b/plugins/sudoers/starttime.c @@ -109,16 +109,14 @@ get_starttime(pid_t pid, struct timespec *starttime) if (rc != -1) { #if defined(HAVE_KINFO_PROC_FREEBSD) /* FreeBSD and Dragonfly */ - starttime->tv_sec = ki_proc->ki_start.tv_sec; - starttime->tv_nsec = ki_proc->ki_start.tv_usec / 1000; + TIMEVAL_TO_TIMESPEC(&ki_proc->ki_start, starttime); #elif defined(HAVE_KINFO_PROC_44BSD) /* 4.4BSD and macOS */ - starttime->tv_sec = ki_proc->kp_proc.p_starttime.tv_sec; - starttime->tv_nsec = ki_proc->kp_proc.p_starttime.tv_usec / 1000; + TIMEVAL_TO_TIMESPEC(&ki_proc->kp_proc.p_starttime, starttime); #else /* NetBSD and OpenBSD */ starttime->tv_sec = ki_proc->p_ustart_sec; - starttime->tv_nsec = ki_proc->p_ustart_usec / 1000; + starttime->tv_nsec = ki_proc->p_ustart_usec * 1000; #endif sudo_debug_printf(SUDO_DEBUG_INFO, "%s: start time for %d: { %lld, %ld }", __func__, -- 2.40.0