mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
updated for version 7.3.648
Problem: Crash when using a very long file name. (ZyX) Solution: Properly check length of buffer space.
This commit is contained in:
parent
57c0ea8692
commit
2c66669c33
31
src/buffer.c
31
src/buffer.c
@ -3234,12 +3234,15 @@ maketitle()
|
|||||||
{
|
{
|
||||||
/* format: "fname + (path) (1 of 2) - VIM" */
|
/* format: "fname + (path) (1 of 2) - VIM" */
|
||||||
|
|
||||||
|
#define SPACE_FOR_FNAME (IOSIZE - 100)
|
||||||
|
#define SPACE_FOR_DIR (IOSIZE - 20)
|
||||||
|
#define SPACE_FOR_ARGNR (IOSIZE - 10) /* at least room for " - VIM" */
|
||||||
if (curbuf->b_fname == NULL)
|
if (curbuf->b_fname == NULL)
|
||||||
vim_strncpy(buf, (char_u *)_("[No Name]"), IOSIZE - 100);
|
vim_strncpy(buf, (char_u *)_("[No Name]"), SPACE_FOR_FNAME);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
p = transstr(gettail(curbuf->b_fname));
|
p = transstr(gettail(curbuf->b_fname));
|
||||||
vim_strncpy(buf, p, IOSIZE - 100);
|
vim_strncpy(buf, p, SPACE_FOR_FNAME);
|
||||||
vim_free(p);
|
vim_free(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3263,7 +3266,7 @@ maketitle()
|
|||||||
buf[off++] = ' ';
|
buf[off++] = ' ';
|
||||||
buf[off++] = '(';
|
buf[off++] = '(';
|
||||||
home_replace(curbuf, curbuf->b_ffname,
|
home_replace(curbuf, curbuf->b_ffname,
|
||||||
buf + off, IOSIZE - off, TRUE);
|
buf + off, SPACE_FOR_DIR - off, TRUE);
|
||||||
#ifdef BACKSLASH_IN_FILENAME
|
#ifdef BACKSLASH_IN_FILENAME
|
||||||
/* avoid "c:/name" to be reduced to "c" */
|
/* avoid "c:/name" to be reduced to "c" */
|
||||||
if (isalpha(buf[off]) && buf[off + 1] == ':')
|
if (isalpha(buf[off]) && buf[off + 1] == ':')
|
||||||
@ -3274,18 +3277,28 @@ maketitle()
|
|||||||
if (p == buf + off)
|
if (p == buf + off)
|
||||||
/* must be a help buffer */
|
/* must be a help buffer */
|
||||||
vim_strncpy(buf + off, (char_u *)_("help"),
|
vim_strncpy(buf + off, (char_u *)_("help"),
|
||||||
(size_t)(IOSIZE - off - 1));
|
(size_t)(SPACE_FOR_DIR - off - 1));
|
||||||
else
|
else
|
||||||
*p = NUL;
|
*p = NUL;
|
||||||
|
|
||||||
/* translate unprintable chars */
|
/* Translate unprintable chars and concatenate. Keep some
|
||||||
p = transstr(buf + off);
|
* room for the server name. When there is no room (very long
|
||||||
vim_strncpy(buf + off, p, (size_t)(IOSIZE - off - 1));
|
* file name) use (...). */
|
||||||
vim_free(p);
|
if (off < SPACE_FOR_DIR)
|
||||||
|
{
|
||||||
|
p = transstr(buf + off);
|
||||||
|
vim_strncpy(buf + off, p, (size_t)(SPACE_FOR_DIR - off));
|
||||||
|
vim_free(p);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
vim_strncpy(buf + off, (char_u *)"...",
|
||||||
|
(size_t)(SPACE_FOR_ARGNR - off));
|
||||||
|
}
|
||||||
STRCAT(buf, ")");
|
STRCAT(buf, ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
append_arg_number(curwin, buf, IOSIZE, FALSE);
|
append_arg_number(curwin, buf, SPACE_FOR_ARGNR, FALSE);
|
||||||
|
|
||||||
#if defined(FEAT_CLIENTSERVER)
|
#if defined(FEAT_CLIENTSERVER)
|
||||||
if (serverName != NULL)
|
if (serverName != NULL)
|
||||||
|
@ -719,6 +719,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
648,
|
||||||
/**/
|
/**/
|
||||||
647,
|
647,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user