summaryrefslogtreecommitdiffstats
path: root/lib/libc/string/wcsncpy.c
diff options
context:
space:
mode:
authorespie <espie@openbsd.org>2006-04-17 18:05:35 +0000
committerespie <espie@openbsd.org>2006-04-17 18:05:35 +0000
commit9ba27af9a3418983a04e124443556db3b3171516 (patch)
treec0ff0aebc6e1cc8b3e5a44e6bc3f8634ef5f3a0c /lib/libc/string/wcsncpy.c
parentSprinkle more debug. Remove 64 byte boundary; it doesn't seem to like it. (diff)
downloadwireguard-openbsd-9ba27af9a3418983a04e124443556db3b3171516.tar.xz
wireguard-openbsd-9ba27af9a3418983a04e124443556db3b3171516.zip
fix badly broken code. okay millert@, deraadt@
Diffstat (limited to 'lib/libc/string/wcsncpy.c')
-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;
}