1fa1ff
To: vim_dev@googlegroups.com
1fa1ff
Subject: Patch 7.4.013
1fa1ff
Fcc: outbox
1fa1ff
From: Bram Moolenaar <Bram@moolenaar.net>
1fa1ff
Mime-Version: 1.0
1fa1ff
Content-Type: text/plain; charset=UTF-8
1fa1ff
Content-Transfer-Encoding: 8bit
1fa1ff
------------
1fa1ff
1fa1ff
Patch 7.4.013
1fa1ff
Problem:    File name buffer too small for utf-8.
1fa1ff
Solution:   Use character count instead of byte count. (Ken Takata)
1fa1ff
Files:	    src/os_mswin.c
1fa1ff
1fa1ff
1fa1ff
*** ../vim-7.4.012/src/os_mswin.c	2013-08-30 16:44:15.000000000 +0200
1fa1ff
--- src/os_mswin.c	2013-08-30 16:47:54.000000000 +0200
1fa1ff
***************
1fa1ff
*** 456,462 ****
1fa1ff
--- 456,469 ----
1fa1ff
      int
1fa1ff
  mch_isFullName(char_u *fname)
1fa1ff
  {
1fa1ff
+ #ifdef FEAT_MBYTE
1fa1ff
+     /* WinNT and later can use _MAX_PATH wide characters for a pathname, which
1fa1ff
+      * means that the maximum pathname is _MAX_PATH * 3 bytes when 'enc' is
1fa1ff
+      * UTF-8. */
1fa1ff
+     char szName[_MAX_PATH * 3 + 1];
1fa1ff
+ #else
1fa1ff
      char szName[_MAX_PATH + 1];
1fa1ff
+ #endif
1fa1ff
  
1fa1ff
      /* A name like "d:/foo" and "//server/share" is absolute */
1fa1ff
      if ((fname[0] && fname[1] == ':' && (fname[2] == '/' || fname[2] == '\\'))
1fa1ff
***************
1fa1ff
*** 464,470 ****
1fa1ff
  	return TRUE;
1fa1ff
  
1fa1ff
      /* A name that can't be made absolute probably isn't absolute. */
1fa1ff
!     if (mch_FullName(fname, szName, _MAX_PATH, FALSE) == FAIL)
1fa1ff
  	return FALSE;
1fa1ff
  
1fa1ff
      return pathcmp(fname, szName, -1) == 0;
1fa1ff
--- 471,477 ----
1fa1ff
  	return TRUE;
1fa1ff
  
1fa1ff
      /* A name that can't be made absolute probably isn't absolute. */
1fa1ff
!     if (mch_FullName(fname, szName, sizeof(szName) - 1, FALSE) == FAIL)
1fa1ff
  	return FALSE;
1fa1ff
  
1fa1ff
      return pathcmp(fname, szName, -1) == 0;
1fa1ff
***************
1fa1ff
*** 498,507 ****
1fa1ff
      int
1fa1ff
  vim_stat(const char *name, struct stat *stp)
1fa1ff
  {
1fa1ff
      char	buf[_MAX_PATH + 1];
1fa1ff
      char	*p;
1fa1ff
  
1fa1ff
!     vim_strncpy((char_u *)buf, (char_u *)name, _MAX_PATH);
1fa1ff
      p = buf + strlen(buf);
1fa1ff
      if (p > buf)
1fa1ff
  	mb_ptr_back(buf, p);
1fa1ff
--- 505,521 ----
1fa1ff
      int
1fa1ff
  vim_stat(const char *name, struct stat *stp)
1fa1ff
  {
1fa1ff
+ #ifdef FEAT_MBYTE
1fa1ff
+     /* WinNT and later can use _MAX_PATH wide characters for a pathname, which
1fa1ff
+      * means that the maximum pathname is _MAX_PATH * 3 bytes when 'enc' is
1fa1ff
+      * UTF-8. */
1fa1ff
+     char	buf[_MAX_PATH * 3 + 1];
1fa1ff
+ #else
1fa1ff
      char	buf[_MAX_PATH + 1];
1fa1ff
+ #endif
1fa1ff
      char	*p;
1fa1ff
  
1fa1ff
!     vim_strncpy((char_u *)buf, (char_u *)name, sizeof(buf) - 1);
1fa1ff
      p = buf + strlen(buf);
1fa1ff
      if (p > buf)
1fa1ff
  	mb_ptr_back(buf, p);
1fa1ff
*** ../vim-7.4.012/src/version.c	2013-08-30 16:44:15.000000000 +0200
1fa1ff
--- src/version.c	2013-08-30 16:47:36.000000000 +0200
1fa1ff
***************
1fa1ff
*** 740,741 ****
1fa1ff
--- 740,743 ----
1fa1ff
  {   /* Add new patch number below this line */
1fa1ff
+ /**/
1fa1ff
+     13,
1fa1ff
  /**/
1fa1ff
1fa1ff
-- 
1fa1ff
hundred-and-one symptoms of being an internet addict:
1fa1ff
143. You dream in pallettes of 216 websafe colors.
1fa1ff
1fa1ff
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
1fa1ff
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
1fa1ff
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
1fa1ff
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///