projects
/
oweals
/
busybox.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
| inline |
side by side
fix all cases of strcpy on overlapping strings.
[oweals/busybox.git]
/
libbb
/
safe_strncpy.c
diff --git
a/libbb/safe_strncpy.c
b/libbb/safe_strncpy.c
index 649fa10cf78052c60271cba48d6a5f83dcca0001..4acd9766ba7c896076826e0f538d7fddc55af8f2 100644
(file)
--- 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)
dst[--size] = '\0';
return strncpy(dst, src, size);
}
+
+/* Like strcpy but can copy overlapping strings. */
+void FAST_FUNC overlapping_strcpy(char *dst, const char *src)
+{
+ while ((*dst = *src) != '\0') {
+ dst++;
+ src++;
+ }
+}