summaryrefslogtreecommitdiff
path: root/libbb/safe_strncpy.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-07-22 20:16:55 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-07-22 20:16:55 +0000
commit0f293b96dc6effa127ec63e11dd16221f1329126 (patch)
treea5b7873a5ece9bef8355da8d437cf53f952c66ca /libbb/safe_strncpy.c
parent68a192c00799fd2097bab1aec594cd27203b1ec6 (diff)
downloadbusybox-w32-0f293b96dc6effa127ec63e11dd16221f1329126.tar.gz
busybox-w32-0f293b96dc6effa127ec63e11dd16221f1329126.tar.bz2
busybox-w32-0f293b96dc6effa127ec63e11dd16221f1329126.zip
fix all cases of strcpy on overlapping strings.
Diffstat (limited to 'libbb/safe_strncpy.c')
-rw-r--r--libbb/safe_strncpy.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/libbb/safe_strncpy.c b/libbb/safe_strncpy.c
index 649fa10cf..4acd9766b 100644
--- a/libbb/safe_strncpy.c
+++ b/libbb/safe_strncpy.c
@@ -16,3 +16,12 @@ char* FAST_FUNC safe_strncpy(char *dst, const char *src, size_t size)
16 dst[--size] = '\0'; 16 dst[--size] = '\0';
17 return strncpy(dst, src, size); 17 return strncpy(dst, src, size);
18} 18}
19
20/* Like strcpy but can copy overlapping strings. */
21void FAST_FUNC overlapping_strcpy(char *dst, const char *src)
22{
23 while ((*dst = *src) != '\0') {
24 dst++;
25 src++;
26 }
27}