Hi,

2018/10/8 Mon 10:50:46 UTC+9 Ken Takata wrote:
> Hi,
> 
> 2016/2/2 Tue 7:11:32 UTC+9 Bram Moolenaar wrote:
> > Ken Takata wrote:
> > 
> > > When 'enc' is utf-8, executable() may fail on very long filename which is
> > > longer than _MAX_PATH bytes in UTF-8 and shorter than _MAX_PATH character 
> > > in
> > > UTF-16.
> > > Here is an example on Japanese Windows:
> > > 
> > > C:\tmp>gvim -N -u NONE --cmd "set enc=utf-8" 
> > > ああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああ.bat
> > > :w
> > > :echo glob('あ*.bat')
> > > ああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああ.bat
> > > :echo strlen(glob('あ*.bat'))
> > > 604   " longer than 260
> > > :echo strchars(glob('あ*.bat'))
> > > 204   " shorter than 260
> > > :echo executable(glob('あ*.bat'))
> > > 0     " 1 is expected.
> > > 
> > > 
> > > Attached patch fixes the problem.
> > 
> > Thanks!
> 
> I have updated the patch for 8.1.0453:
> 
> * Fixed conflicts.
> * Fixed a typo in a comment which was added in 8.1.0453.

I have updated the patch for the latest source code:

* Fixed conflicts.
* Use C++ style comments.

Regards,
Ken Takata

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
# HG changeset patch
# Parent 6ee3a815113c128147fa9831c2004916a7daba86
# Parent  54b1387be17d939d03f3c1abc54ad15387e64c31

diff --git a/src/os_win32.c b/src/os_win32.c
--- a/src/os_win32.c
+++ b/src/os_win32.c
@@ -3515,14 +3515,17 @@ mch_writable(char_u *name)
     int
 mch_can_exe(char_u *name, char_u **path, int use_path)
 {
-    char_u	buf[_MAX_PATH];
+    // WinNT and later can use _MAX_PATH wide characters for a pathname, which
+    // means that the maximum pathname is _MAX_PATH * 3 bytes when 'enc' is
+    // UTF-8.
+    char_u	buf[_MAX_PATH * 3];
     int		len = (int)STRLEN(name);
     char_u	*p, *saved;
 
-    if (len >= _MAX_PATH)	/* safety check */
+    if (len >= sizeof(buf))	// safety check
 	return FALSE;
 
-    /* Ty using the name directly when a Unix-shell like 'shell'. */
+    // Try using the name directly when a Unix-shell like 'shell'.
     if (strstr((char *)gettail(p_sh), "sh") != NULL)
 	if (executable_exists((char *)name, path, use_path))
 	    return TRUE;
@@ -3555,7 +3558,7 @@ mch_can_exe(char_u *name, char_u **path,
     }
     vim_free(saved);
 
-    vim_strncpy(buf, name, _MAX_PATH - 1);
+    vim_strncpy(buf, name, sizeof(buf) - 1);
     p = mch_getenv("PATHEXT");
     if (p == NULL)
 	p = (char_u *)".com;.exe;.bat;.cmd";
@@ -3570,7 +3573,7 @@ mch_can_exe(char_u *name, char_u **path,
 		++p;
 	}
 	else
-	    copy_option_part(&p, buf + len, _MAX_PATH - len, ";");
+	    copy_option_part(&p, buf + len, sizeof(buf) - len, ";");
 	if (executable_exists((char *)buf, path, use_path))
 	    return TRUE;
     }

Raspunde prin e-mail lui