mirror of
git://git.sv.gnu.org/nano.git
synced 2025-02-12 19:34:18 +03:00
tabbing: properly terminate the answer when the sole match is a folder
When there is just one match when <Tab> is pressed, and this match is a directory, then a slash is added to 'shared', overwriting the terminating NUL character. So, strcpy() cannot be used for copying this 'shared' string, but strncpy() is needed, and the result needs to be NUL terminated afterward. This fixes https://savannah.gnu.org/bugs/?58826. Bug existed since commit b0f56398 from eleven days ago.
This commit is contained in:
parent
5ca4e9f5b3
commit
7157f5a3ce
@ -2566,7 +2566,8 @@ char *input_tab(char *morsel, size_t *place, void (*refresh_func)(void), bool *l
|
||||
/* If the matches have something in common, copy that part. */
|
||||
if (common_len != *place) {
|
||||
morsel = charealloc(morsel, common_len + 1);
|
||||
strcpy(morsel, shared);
|
||||
strncpy(morsel, shared, common_len);
|
||||
morsel[common_len] = '\0';
|
||||
*place = common_len;
|
||||
} else if (num_matches == 1)
|
||||
beep();
|
||||
|
Loading…
x
Reference in New Issue
Block a user