summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorespie <>2006-04-17 18:05:35 +0000
committerespie <>2006-04-17 18:05:35 +0000
commitd9802fbcccff2f710cb1a8a8d8de57ea8167e591 (patch)
tree6ba8bffd013e7c6e04c5daa16c8609361a69ed4e
parent04261074d345653277ced7adf044ea87ac7c93cc (diff)
downloadopenbsd-d9802fbcccff2f710cb1a8a8d8de57ea8167e591.tar.gz
openbsd-d9802fbcccff2f710cb1a8a8d8de57ea8167e591.tar.bz2
openbsd-d9802fbcccff2f710cb1a8a8d8de57ea8167e591.zip
fix badly broken code. okay millert@, deraadt@
-rw-r--r--src/lib/libc/string/wcsncpy.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/lib/libc/string/wcsncpy.c b/src/lib/libc/string/wcsncpy.c
index 5da7edb06e..107696f1de 100644
--- a/src/lib/libc/string/wcsncpy.c
+++ b/src/lib/libc/string/wcsncpy.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: wcsncpy.c,v 1.3 2005/08/08 08:05:37 espie Exp $ */ 1/* $OpenBSD: wcsncpy.c,v 1.4 2006/04/17 18:05:35 espie Exp $ */
2/* $NetBSD: wcsncpy.c,v 1.2 2001/01/03 14:29:37 lukem Exp $ */ 2/* $NetBSD: wcsncpy.c,v 1.2 2001/01/03 14:29:37 lukem Exp $ */
3 3
4/*- 4/*-
@@ -35,16 +35,16 @@ wchar_t *
35wcsncpy(wchar_t *s1, const wchar_t *s2, size_t n) 35wcsncpy(wchar_t *s1, const wchar_t *s2, size_t n)
36{ 36{
37 wchar_t *p; 37 wchar_t *p;
38 const wchar_t *q;
39 38
40 *s1 = '\0';
41 p = s1; 39 p = s1;
42 q = s2; 40 while (n && *s2) {
43 while (n && *q) { 41 *p++ = *s2++;
44 *p++ = *q++; 42 n--;
43 }
44 while (n) {
45 *p++ = L'\0';
45 n--; 46 n--;
46 } 47 }
47 *p = '\0';
48 48
49 return s1; 49 return s1;
50} 50}