summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
authornaddy <naddy@openbsd.org>2012-07-11 10:44:59 +0000
committernaddy <naddy@openbsd.org>2012-07-11 10:44:59 +0000
commit54f88401828475935abe897b54c44171ea937b48 (patch)
tree39b27c4b739251e23c225d89a787b6c6f34c7de6 /lib/libc
parentUnbreak the tree for gcc2 arches. (diff)
downloadwireguard-openbsd-54f88401828475935abe897b54c44171ea937b48.tar.xz
wireguard-openbsd-54f88401828475935abe897b54c44171ea937b48.zip
fix an off-by-one error where the return value would point to the
character after the '\0'; ok guenther@
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/string/stpncpy.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/libc/string/stpncpy.c b/lib/libc/string/stpncpy.c
index b772486d59c..c7c2a57c4cd 100644
--- a/lib/libc/string/stpncpy.c
+++ b/lib/libc/string/stpncpy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: stpncpy.c,v 1.1 2012/01/17 02:48:01 guenther Exp $ */
+/* $OpenBSD: stpncpy.c,v 1.2 2012/07/11 10:44:59 naddy Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@@ -44,7 +44,7 @@ stpncpy(char *dst, const char *src, size_t n)
dst = &dst[n];
do {
if ((*d++ = *s++) == 0) {
- dst = d;
+ dst = d - 1;
/* NUL pad the remaining n-1 bytes */
while (--n != 0)
*d++ = 0;