- don't free user-supplied string (via -e)
[oweals/busybox.git] / libbb / lineedit.c
index a46b5d2c41c25fed4fc6a8c1c047141a58b3d675..3e16f642311c3e95c9488c6f5cfb4c3fac53326a 100644 (file)
@@ -345,7 +345,7 @@ static void input_delete(int save)
        }
 #endif
 
-       strcpy(command_ps + j, command_ps + j + 1);
+       overlapping_strcpy(command_ps + j, command_ps + j + 1);
        command_len--;
        input_end();                    /* rewrite new line */
        cmdedit_set_out_char(' ');      /* erase char */
@@ -989,7 +989,7 @@ static void load_history(const char *fromfile)
 
        /* NB: do not trash old history if file can't be opened */
 
-       fp = fopen(fromfile, "r");
+       fp = fopen_for_read(fromfile);
        if (fp) {
                /* clean up old history */
                for (hi = state->cnt_history; hi > 0;) {
@@ -1022,7 +1022,7 @@ static void save_history(const char *tofile)
 {
        FILE *fp;
 
-       fp = fopen(tofile, "w");
+       fp = fopen_for_write(tofile);
        if (fp) {
                int i;
 
@@ -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);
                        }