summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2005-10-29 23:48:05 +1000
committerHerbert Xu <herbert@gondor.apana.org.au>2005-10-29 23:48:05 +1000
commita5570fb5a13b49eaf6f7b3db3d9341b596fdfc38 (patch)
tree833c12104854fb8cd7b584376661be77d48ac307 /src
parent[SYSTEM] Added out-of-line ctypes functions for klibc (diff)
downloaddash-a5570fb5a13b49eaf6f7b3db3d9341b596fdfc38.tar.gz
dash-a5570fb5a13b49eaf6f7b3db3d9341b596fdfc38.zip
[SYSTEM] Fixed fallback stpcpy implementation
The implementation has an off-by-one bug.  This results in random memory
corruption.  In one particular case, it caused certain bits of a function
body to go missing.
Diffstat (limited to 'src')
-rw-r--r--src/system.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/system.c b/src/system.c
index c6bc52d..5fd6062 100644
--- a/src/system.c
+++ b/src/system.c
@@ -71,7 +71,9 @@ void *mempcpy(void *dest, const void *src, size_t n)
 #ifndef HAVE_STPCPY
 char *stpcpy(char *dest, const char *src)
 {
-	return mempcpy(dest, src, strlen(src) + 1);
+	size_t len = strlen(src);
+	dest[len] = 0;
+	return mempcpy(dest, src, len);
 }
 #endif