summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2008-01-02 17:57:50 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2008-01-02 17:57:50 +0000
commit55d7cbba94b38ffd71c55b2ed72c2ac03c06cb25 (patch)
treef457a6cc38dacaf23ca9e18a0bd6a7528a79c3d4
parente987517b4cc0fd7e5242b625b98d8583608f5717 (diff)
Do not lose nanosleep() return value in the last copyout if nonzero; PR#5697
-rw-r--r--sys/kern/kern_time.c8
1 files changed, 5 insertions, 3 deletions
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;