vim-patch:8.2.3487: illegal memory access if buffer name is very long

Problem:    Illegal memory access if buffer name is very long.
Solution:   Make sure not to go over the end of the buffer.
826bfe4bbd

Adjust the test to use :noswapfile, as Nvim fails to create the swap file on Windows due to the file
name's length (E303).

We don't have this behaviour on Linux as we get "[Permission denied]" from readfile(), so there is
no attempt to create the swap file. However, Vim doesn't try to create the swap file on Windows
either for a different reason: MAXPATHL in Vim for Windows is only 1024 (compared to Nvim's 4096 on
the Windows CI), so readfile() gives "Illegal file name" instead, thus not needing :noswapfile for
both cases.
This commit is contained in:
Sean Dewar
2021-10-08 20:44:58 +01:00
committed by zeertzjq
parent fc954d0a61
commit 76e6b81b23
2 changed files with 17 additions and 5 deletions

View File

@@ -5173,19 +5173,19 @@ static void win_redr_status(win_T *wp)
*(p + len++) = ' ';
}
if (bt_help(wp->w_buffer)) {
STRCPY(p + len, _("[Help]"));
snprintf((char *)p + len, MAXPATHL - len, "%s", _("[Help]"));
len += (int)STRLEN(p + len);
}
if (wp->w_p_pvw) {
STRCPY(p + len, _("[Preview]"));
snprintf((char *)p + len, MAXPATHL - len, "%s", _("[Preview]"));
len += (int)STRLEN(p + len);
}
if (bufIsChanged(wp->w_buffer)) {
STRCPY(p + len, "[+]");
len += 3;
snprintf((char *)p + len, MAXPATHL - len, "%s", "[+]");
len += (int)STRLEN(p + len);
}
if (wp->w_buffer->b_p_ro) {
STRCPY(p + len, _("[RO]"));
snprintf((char *)p + len, MAXPATHL - len, "%s", _("[RO]"));
// len += (int)STRLEN(p + len); // dead assignment
}