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