Skip to content

Commit be17bc2

Browse files
committed
updated for version 7.4.013
Problem: File name buffer too small for utf-8. Solution: Use character count instead of byte count. (Ken Takata)
1 parent d7d89c9 commit be17bc2

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/os_mswin.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,15 +456,22 @@ mch_FullName(
456456
int
457457
mch_isFullName(char_u *fname)
458458
{
459+
#ifdef FEAT_MBYTE
460+
/* WinNT and later can use _MAX_PATH wide characters for a pathname, which
461+
* means that the maximum pathname is _MAX_PATH * 3 bytes when 'enc' is
462+
* UTF-8. */
463+
char szName[_MAX_PATH * 3 + 1];
464+
#else
459465
char szName[_MAX_PATH + 1];
466+
#endif
460467

461468
/* A name like "d:/foo" and "//server/share" is absolute */
462469
if ((fname[0] && fname[1] == ':' && (fname[2] == '/' || fname[2] == '\\'))
463470
|| (fname[0] == fname[1] && (fname[0] == '/' || fname[0] == '\\')))
464471
return TRUE;
465472

466473
/* A name that can't be made absolute probably isn't absolute. */
467-
if (mch_FullName(fname, szName, _MAX_PATH, FALSE) == FAIL)
474+
if (mch_FullName(fname, szName, sizeof(szName) - 1, FALSE) == FAIL)
468475
return FALSE;
469476

470477
return pathcmp(fname, szName, -1) == 0;
@@ -498,10 +505,17 @@ slash_adjust(p)
498505
int
499506
vim_stat(const char *name, struct stat *stp)
500507
{
508+
#ifdef FEAT_MBYTE
509+
/* WinNT and later can use _MAX_PATH wide characters for a pathname, which
510+
* means that the maximum pathname is _MAX_PATH * 3 bytes when 'enc' is
511+
* UTF-8. */
512+
char buf[_MAX_PATH * 3 + 1];
513+
#else
501514
char buf[_MAX_PATH + 1];
515+
#endif
502516
char *p;
503517

504-
vim_strncpy((char_u *)buf, (char_u *)name, _MAX_PATH);
518+
vim_strncpy((char_u *)buf, (char_u *)name, sizeof(buf) - 1);
505519
p = buf + strlen(buf);
506520
if (p > buf)
507521
mb_ptr_back(buf, p);

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,8 @@ static char *(features[]) =
738738

739739
static int included_patches[] =
740740
{ /* Add new patch number below this line */
741+
/**/
742+
13,
741743
/**/
742744
12,
743745
/**/

0 commit comments

Comments
 (0)