aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
Diffstat (limited to 'libbb')
-rw-r--r--libbb/lineedit.c2
-rw-r--r--libbb/parse_config.c2
-rw-r--r--libbb/safe_strncpy.c9
3 files changed, 11 insertions, 2 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index 2e16e6a0a..032da24e7 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -1552,7 +1552,7 @@ int FAST_FUNC read_line_input(const char *prompt, char *command, int maxsize, li
vi_case(CTRL('U')|vbit:)
/* Control-U -- Clear line before cursor */
if (cursor) {
- strcpy(command, command + cursor);
+ overlapping_strcpy(command, command + cursor);
command_len -= cursor;
redraw(cmdedit_y, command_len);
}
diff --git a/libbb/parse_config.c b/libbb/parse_config.c
index 5109066d8..d1b29218b 100644
--- a/libbb/parse_config.c
+++ b/libbb/parse_config.c
@@ -161,7 +161,7 @@ int FAST_FUNC config_read(parser_t *parser, char **tokens, unsigned flags, const
int n = strspn(line, delims);
if (n) {
ii -= n;
- strcpy(line, line + n);
+ overlapping_strcpy(line, line + n);
}
// cut trailing
if (ii) {
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)
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++;
+ }
+}