@@ -3299,14 +3299,17 @@ mch_writable(char_u *name)
32993299 int
33003300mch_can_exe (char_u * name , char_u * * path , int use_path )
33013301{
3302- char_u buf [_MAX_PATH ];
3302+ // WinNT and later can use _MAX_PATH wide characters for a pathname, which
3303+ // means that the maximum pathname is _MAX_PATH * 3 bytes when 'enc' is
3304+ // UTF-8.
3305+ char_u buf [_MAX_PATH * 3 ];
33033306 int len = (int )STRLEN (name );
33043307 char_u * p , * saved ;
33053308
3306- if (len >= _MAX_PATH ) /* safety check */
3309+ if (len >= sizeof ( buf )) // safety check
33073310 return FALSE;
33083311
3309- /* Ty using the name directly when a Unix-shell like 'shell'. */
3312+ // Try using the name directly when a Unix-shell like 'shell'.
33103313 if (strstr ((char * )gettail (p_sh ), "sh" ) != NULL )
33113314 if (executable_exists ((char * )name , path , use_path ))
33123315 return TRUE;
@@ -3339,7 +3342,7 @@ mch_can_exe(char_u *name, char_u **path, int use_path)
33393342 }
33403343 vim_free (saved );
33413344
3342- vim_strncpy (buf , name , _MAX_PATH - 1 );
3345+ vim_strncpy (buf , name , sizeof ( buf ) - 1 );
33433346 p = mch_getenv ("PATHEXT" );
33443347 if (p == NULL )
33453348 p = (char_u * )".com;.exe;.bat;.cmd" ;
@@ -3354,7 +3357,7 @@ mch_can_exe(char_u *name, char_u **path, int use_path)
33543357 ++ p ;
33553358 }
33563359 else
3357- copy_option_part (& p , buf + len , _MAX_PATH - len , ";" );
3360+ copy_option_part (& p , buf + len , sizeof ( buf ) - len , ";" );
33583361 if (executable_exists ((char * )buf , path , use_path ))
33593362 return TRUE;
33603363 }
0 commit comments