summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2006-04-17 18:05:36 +0000
committerMarc Espie <espie@cvs.openbsd.org>2006-04-17 18:05:36 +0000
commitf47145b744ba492e88b0f0c20f3e0b43b555fec3 (patch)
treeedaeceb8d33b6de8156ad6c881df5719d0966c32
parent353d31b7a17072c30d4f9353cac3b609eb64cf73 (diff)
fix badly broken code. okay millert@, deraadt@
-rw-r--r--lib/libc/string/wcsncpy.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/libc/string/wcsncpy.c b/lib/libc/string/wcsncpy.c
index 5da7edb06e4..107696f1de4 100644
--- a/lib/libc/string/wcsncpy.c
+++ b/lib/libc/string/wcsncpy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wcsncpy.c,v 1.3 2005/08/08 08:05:37 espie Exp $ */
+/* $OpenBSD: wcsncpy.c,v 1.4 2006/04/17 18:05:35 espie Exp $ */
/* $NetBSD: wcsncpy.c,v 1.2 2001/01/03 14:29:37 lukem Exp $ */
/*-
@@ -35,16 +35,16 @@ wchar_t *
wcsncpy(wchar_t *s1, const wchar_t *s2, size_t n)
{
wchar_t *p;
- const wchar_t *q;
- *s1 = '\0';
p = s1;
- q = s2;
- while (n && *q) {
- *p++ = *q++;
+ while (n && *s2) {
+ *p++ = *s2++;
+ n--;
+ }
+ while (n) {
+ *p++ = L'\0';
n--;
}
- *p = '\0';
return s1;
}