summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2002-01-21 19:48:55 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2002-01-21 19:48:55 +0000
commita2237bb40aaea5e8de7a98029e06cbfae72b1a31 (patch)
treeb9af53f8204176dedde96edaa4da6980c5a05280 /sys/arch
parent8cd50d6fdf12d1fb65860a249d0a5e9a2b065996 (diff)
Always clear the destination string in copyinstr() on error, unless we faulted
when writing to the first character. With some help from millert@.
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/m68k/m68k/copy.s9
1 files changed, 7 insertions, 2 deletions
diff --git a/sys/arch/m68k/m68k/copy.s b/sys/arch/m68k/m68k/copy.s
index 6f1aef094dc..ca33c7d49d7 100644
--- a/sys/arch/m68k/m68k/copy.s
+++ b/sys/arch/m68k/m68k/copy.s
@@ -1,4 +1,4 @@
-/* $OpenBSD: copy.s,v 1.11 2001/06/27 04:39:05 art Exp $ */
+/* $OpenBSD: copy.s,v 1.12 2002/01/21 19:48:54 miod Exp $ */
/* $NetBSD: copy.s,v 1.30 1998/03/04 06:39:14 thorpej Exp $ */
/*-
@@ -261,6 +261,9 @@ Lcisloop:
bcc Lcisloop | more room, keep going
Lcistoolong:
moveq #ENAMETOOLONG,d0 | ran out of space
+Lcisnull:
+ subql #1, a1
+ clrb a1@+ | clear last byte
Lcisdone:
tstl sp@(16) | length desired?
beq Lcisexit
@@ -273,7 +276,9 @@ Lcisexit:
rts
Lcisfault:
moveq #EFAULT,d0
- bra Lcisdone
+ cmpl sp@(8),a1 | do not attempt to clear last byte
+ beq Lcisdone | if we faulted on first write
+ bra Lcisnull
/*
* copyoutstr(caddr_t from, caddr_t to, size_t maxlen, size_t *lencopied);