com php-src: Fix bug #78094: File Search Problem Excessive Time: win32/ioutil.c
| From: | Christoph Michael Becker | Date: | Thu, 06 Jun 2019 13:55:46 +0000 |
| Subject: | com php-src: Fix bug #78094: File Search Problem Excessive Time: win32/ioutil.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-106596@lists.php.net to get a copy of this message | ||
Commit: f5b44c7e8a55978b5e3c3511b310ab8f09beaa97
Author: Christoph M. Becker <cmbecker69@gmx.de> Thu, 6 Jun 2019 15:54:12 +0200
Parents: c358c280df6e81facad4045320cfdb1149a91463
Branches: PHP-7.4 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=f5b44c7e8a55978b5e3c3511b310ab8f09beaa97
Log:
Fix bug #78094: File Search Problem Excessive Time
Instead of checking GetBinaryType() for each file, we do a much cheaper
pre-check whether the filename extension matches .exe or .com, and call
GetBinaryType() only in this case. For BC we also report .bat and .cmd
files as executables again.
The patch has been provided by @weltling.
Bugs:
https://bugs.php.net/78094
Changed paths:
M win32/ioutil.c
Diff:
diff --git a/win32/ioutil.c b/win32/ioutil.c
index 7f89481..669876d 100644
--- a/win32/ioutil.c
+++ b/win32/ioutil.c
@@ -925,9 +925,19 @@ static int php_win32_ioutil_fstat_int(HANDLE h, php_win32_ioutil_stat_t *buf,
co
buf->st_mode = 0;
if (!is_dir) {
- DWORD type;
- if (GetBinaryTypeW(pathw, &type)) {
+ if (pathw_len >= 4 &&
+ pathw[pathw_len-4] == L'.') {
+ if (_wcsnicmp(pathw+pathw_len-3, L"exe", 3) == 0 ||
+ _wcsnicmp(pathw+pathw_len-3, L"com", 3) == 0) {
+ DWORD type;
+ if (GetBinaryTypeW(pathw, &type)) {
+ buf->st_mode |= (S_IEXEC|(S_IEXEC>>3)|(S_IEXEC>>6));
+ }
+ /* The below is actually incorrect, but keep for BC. */
+ } else if (_wcsnicmp(pathw+pathw_len-3, L"bat", 3) == 0 ||
+ _wcsnicmp(pathw+pathw_len-3, L"cmd", 3) == 0) {
buf->st_mode |= (S_IEXEC|(S_IEXEC>>3)|(S_IEXEC>>6));
+ }
}
}