php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74866 extension_dir = "./ext" now use current directory for base
Submitted: 2017-07-06 12:27 UTC Modified: 2017-07-08 20:59 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: sailormax at inbox dot lv Assigned: francois (profile)
Status: Closed Package: Dynamic loading
PHP Version: 7.2.0alpha3 OS: Windows 10
Private report: No CVE-ID: None
 [2017-07-06 12:27 UTC] sailormax at inbox dot lv
Description:
------------
Early builds works with "./" in `extension_dir` setting as with directory of php.exe

Start from 7.2alpha3 "./" in `extension_dir` setting PHP start to understand as `current directory`.
In result if start php.exe from any other directory, it try to load extensions from `current directory`.

Test script:
---------------
php.ini:

extension_dir = ".\ext"
extension=php_bz2.dll

exec php from parent directory:
> php\php.exe --version

Expected result:
----------------
PHP 7.2.0alpha3 (cli) ...

Actual result:
--------------
Warning: Cannot access dynamic library 'php_bz2.dll' (tried : ext\php_bz2.dll, ext\php_php_bz2.dll.dll) in Unknown on line 0

PHP 7.2.0alpha3 (cli) ...

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-07-06 15:10 UTC] requinix@php.net
-Status: Open +Status: Verified -Assigned To: +Assigned To: francois
 [2017-07-06 15:10 UTC] requinix@php.net
Caused by the extension loading changes added in alpha3.
https://wiki.php.net/rfc/load-ext-by-name
https://github.com/php/php-src/pull/1741

alpha2 constructed a DLL filename and went straight to DL_LOAD/LoadLibrary, which looks relative to the process.
alpha3 also constructs a filename but first tests the path with VCWD_ACCESS/tsrm_win32_access, which itself tests access to the parent directory.
 [2017-07-06 15:11 UTC] requinix@php.net
(...and tsrm_win32_access looks relative to the current working directory.)
 [2017-07-06 18:27 UTC] ab@php.net
@sailormax at inbox dot lv are you sure your php dir is not on PATH?

@requinix the explanation is not correct. It never worked the way it'd search relative to the binary image directory, and unlikely ever will. See this docs

https://msdn.microsoft.com/en-us/library/windows/desktop/ms682586%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396
https://msdn.microsoft.com/en-us/library/windows/desktop/ms684175%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396

In particular, this quote

[start]
The first directory searched is the directory containing the image file used to create the calling process (for more information, see the CreateProcess function). Doing this allows private dynamic-link library (DLL) files associated with a process to be found without adding the process's installed directory to the PATH environment variable. If a relative path is specified, the entire relative path is appended to every token in the DLL search path list. 
[end]

Disregarding that, the patch is a really breaching change. The name like "php_php_bz2.dll.dll" tells, it doesn't even check the ext filename already has a suffix. More breaches are to expect on Windows

Thanks.
 [2017-07-06 18:38 UTC] spam2 at rhsoft dot net
frankly people should *really* stop using relative paths at all for configurations - subscribe to bugtraq@securityfocus.com and it don't take that long to realize how stupid such configurations are
 [2017-07-06 19:08 UTC] ab@php.net
@spam2 at rhsoft dot net sure, but it should not happen as a side effect of another patch. For now I'd say, the behavior should be fixed.

Thanks.
 [2017-07-06 21:26 UTC] francois@php.net
@ab@php.net Sure, this is a BC break. It must be fixed before the release.

I'll take time tomorrow to work on it.
 [2017-07-06 23:11 UTC] ab@php.net
@francois nice. Please let me know, if you need something to be tested.

Thanks.
 [2017-07-07 07:00 UTC] sailormax at inbox dot lv
@ab at php dot net I did not have php dir on PATH.

@spam2 at rhsoft dot net
About "people should *really* stop using relative paths at all for configurations"
I use php.exe and few dlls as portable launcher of code verifier in my portable text editor => I can't use absolute paths and I want not setup php on each computer before use it; I want just copy directory or just plug in USB flash card with my editor and php verifier before use it. Please, don't break this possibility.
 [2017-07-08 20:59 UTC] ab@php.net
-Status: Verified +Status: Feedback
 [2017-07-08 20:59 UTC] ab@php.net
There's now a snapshot http://windows.php.net/downloads/snaps/ostc/74866/ based on the Francois PR https://github.com/php/php-src/pull/2612 . Please check.

Thanks.
 [2017-07-10 08:36 UTC] sailormax at inbox dot lv
@ab at php dot net

Dix of Francois work fine. My problem solved. Thanks!
 [2017-07-10 08:37 UTC] sailormax at inbox dot lv
@ab at php dot net

Fix of Francois work fine. My problem solved. Thanks!
 [2017-07-13 12:34 UTC] ab@php.net
Automatic comment on behalf of francois
Revision: http://git.php.net/?p=php-src.git;a=commit;h=0782a7fc6314c8bd3cbfd57f12d0479bf9cc8dc7
Log: Fixed bug #74866 extension_dir = "./ext" now use current directory for base
 [2017-07-13 12:34 UTC] ab@php.net
-Status: Feedback +Status: Closed
 [2020-04-26 19:16 UTC] laurinkeithdavis at gmail dot com
7.4.4 on Windows, this appears to be happening again.

php.ini for both has this setting.

extension_dir = "./ext/"

7.4:

c:\jenkins-php-tools>C:\PHP\php.exe -cc:/PHP/devrc/php.ini
Warning: PHP Startup: Failed to load ./ext/php_curl.dll, The system cannot find the file specified.
 in Unknown on line 0
Warning: PHP Startup: Failed to load ./ext/php_fileinfo.dll, The system cannot find the file specified.
 in Unknown on line 0
Warning: PHP Startup: Failed to load ./ext/php_gd2.dll, The system cannot find the file specified.
 in Unknown on line 0

7.3.16:

c:\jenkins-php-tools>C:\PHP\php.exe -cc:/PHP/devrc/php.ini


(loads, no errors)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 08:01:29 2024 UTC