Merge branch 'security' into 'master'

Security

Closes GL#18, GL#19, GL#20, GL#21

See merge request irssi/irssi!29

(cherry picked from commit 9df3d92598)
This commit is contained in:
Nei 2018-01-04 22:29:29 +00:00 committed by ailin-nemui
commit aea5802519
4 changed files with 28 additions and 9 deletions

View file

@ -186,12 +186,18 @@ char *word_complete(WINDOW_REC *window, const char *line, int *pos, int erase, i
char *old;
old = linestart;
linestart = *linestart == '\0' ?
g_strdup(word) :
g_strdup_printf("%s%c%s",
/* do not accidentally duplicate the word separator */
line == wordstart - 1 ? "" : linestart,
old_wordstart[-1], word);
/* we want to move word into linestart */
if (*linestart == '\0') {
linestart = g_strdup(word);
} else {
GString *str = g_string_new(linestart);
if (old_wordstart[-1] != str->str[str->len - 1]) {
/* do not accidentally duplicate the word separator */
g_string_append_c(str, old_wordstart[-1]);
}
g_string_append(str, word);
linestart = g_string_free(str, FALSE);
}
g_free(old);
g_free(word);