From 55d7cbba94b38ffd71c55b2ed72c2ac03c06cb25 Mon Sep 17 00:00:00 2001 From: Miod Vallat Date: Wed, 2 Jan 2008 17:57:50 +0000 Subject: Do not lose nanosleep() return value in the last copyout if nonzero; PR#5697 --- sys/kern/kern_time.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'sys') diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c index 78e1c7fbd95..d2d8ddae120 100644 --- a/sys/kern/kern_time.c +++ b/sys/kern/kern_time.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_time.c,v 1.62 2007/04/04 17:32:20 art Exp $ */ +/* $OpenBSD: kern_time.c,v 1.63 2008/01/02 17:57:49 miod Exp $ */ /* $NetBSD: kern_time.c,v 1.20 1996/02/18 11:57:06 fvdl Exp $ */ /* @@ -257,7 +257,7 @@ sys_nanosleep(struct proc *p, void *v, register_t *retval) struct timespec rqt, rmt; struct timespec sts, ets; struct timeval tv; - int error; + int error, error1; error = copyin((const void *)SCARG(uap, rqtp), (void *)&rqt, sizeof(struct timespec)); @@ -287,8 +287,10 @@ sys_nanosleep(struct proc *p, void *v, register_t *retval) if (rmt.tv_sec < 0) timespecclear(&rmt); - error = copyout((void *)&rmt, (void *)SCARG(uap,rmtp), + error1 = copyout((void *)&rmt, (void *)SCARG(uap,rmtp), sizeof(rmt)); + if (error1 != 0) + error = error1; } return error; -- cgit v1.2.3