Fix conversion of usec to nsec; from Scott Cheloha

This commit is contained in:
Todd C. Miller
2018-06-04 20:00:41 -06:00
parent dafb5f523a
commit ec2dae8104

View File

@@ -109,16 +109,14 @@ get_starttime(pid_t pid, struct timespec *starttime)
if (rc != -1) { if (rc != -1) {
#if defined(HAVE_KINFO_PROC_FREEBSD) #if defined(HAVE_KINFO_PROC_FREEBSD)
/* FreeBSD and Dragonfly */ /* FreeBSD and Dragonfly */
starttime->tv_sec = ki_proc->ki_start.tv_sec; TIMEVAL_TO_TIMESPEC(&ki_proc->ki_start, starttime);
starttime->tv_nsec = ki_proc->ki_start.tv_usec / 1000;
#elif defined(HAVE_KINFO_PROC_44BSD) #elif defined(HAVE_KINFO_PROC_44BSD)
/* 4.4BSD and macOS */ /* 4.4BSD and macOS */
starttime->tv_sec = ki_proc->kp_proc.p_starttime.tv_sec; TIMEVAL_TO_TIMESPEC(&ki_proc->kp_proc.p_starttime, starttime);
starttime->tv_nsec = ki_proc->kp_proc.p_starttime.tv_usec / 1000;
#else #else
/* NetBSD and OpenBSD */ /* NetBSD and OpenBSD */
starttime->tv_sec = ki_proc->p_ustart_sec; 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 #endif
sudo_debug_printf(SUDO_DEBUG_INFO, sudo_debug_printf(SUDO_DEBUG_INFO,
"%s: start time for %d: { %lld, %ld }", __func__, "%s: start time for %d: { %lld, %ld }", __func__,