diff options
author | naddy <> | 2012-07-11 10:44:59 +0000 |
---|---|---|
committer | naddy <> | 2012-07-11 10:44:59 +0000 |
commit | e1fe34b2d493d33174e80455cc4c8962feae4333 (patch) | |
tree | 4a852520c0405956f4b57e9ce40b09fb9f400056 | |
parent | 66f59da201624034955ba4e99a22d6e7c8ea5c82 (diff) | |
download | openbsd-e1fe34b2d493d33174e80455cc4c8962feae4333.tar.gz openbsd-e1fe34b2d493d33174e80455cc4c8962feae4333.tar.bz2 openbsd-e1fe34b2d493d33174e80455cc4c8962feae4333.zip |
fix an off-by-one error where the return value would point to the
character after the '\0'; ok guenther@
-rw-r--r-- | src/lib/libc/string/stpncpy.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/lib/libc/string/stpncpy.c b/src/lib/libc/string/stpncpy.c index b772486d59..c7c2a57c4c 100644 --- a/src/lib/libc/string/stpncpy.c +++ b/src/lib/libc/string/stpncpy.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: stpncpy.c,v 1.1 2012/01/17 02:48:01 guenther Exp $ */ | 1 | /* $OpenBSD: stpncpy.c,v 1.2 2012/07/11 10:44:59 naddy Exp $ */ |
2 | 2 | ||
3 | /*- | 3 | /*- |
4 | * Copyright (c) 1990 The Regents of the University of California. | 4 | * Copyright (c) 1990 The Regents of the University of California. |
@@ -44,7 +44,7 @@ stpncpy(char *dst, const char *src, size_t n) | |||
44 | dst = &dst[n]; | 44 | dst = &dst[n]; |
45 | do { | 45 | do { |
46 | if ((*d++ = *s++) == 0) { | 46 | if ((*d++ = *s++) == 0) { |
47 | dst = d; | 47 | dst = d - 1; |
48 | /* NUL pad the remaining n-1 bytes */ | 48 | /* NUL pad the remaining n-1 bytes */ |
49 | while (--n != 0) | 49 | while (--n != 0) |
50 | *d++ = 0; | 50 | *d++ = 0; |