[php-src] PR #16687: Fix GH-10992: Improper long path support for relative paths
| From: | cmb69 | Date: | Sun, 03 Nov 2024 13:48:11 +0000 |
| Subject: | [php-src] PR #16687: Fix GH-10992: Improper long path support for relative paths | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-29492@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/16687
Author: cmb69
Relative paths are passed to the ioutils APIs, these are not properly converted to long paths. If
the path length already exceeds a given threshold (usually 259 characters, but only 247 for
mkdir()), the long path prefix is prepended, resulting in an invalid path, since long
paths have to be absolute. If the path length does not exceed that threshold, no conversion to a
long path is done, although that may be necessary.
Thus we take the path length of the current working directory into account when checking the
threshold, and prepend it to the filename if necessary.
Since this is only relevant for NTS builds, and using the current working directory of the process
would be erroneous for ZTS builds, we skip the new code for ZTS builds.
---
Note that I chose the least intrusive solution I could think of since I would like to fix this issue
for stable branches; still, I'm not absolutely sure that this patch may not have inadvertent
side effects, so I've targeted PHP-8.4 for now.
I think in the long run the whole ioutil code should be reviewed and overhauled. I doubt that the
heavy inlining is reasonable, especially considering the many (re-)allocations of buffers (all using
native Windows malloc() and friends which are supposed to be relatively slow), and some
operations might be simplified (possibly at the cost of some runtime performance loss, which may not
really matter here). Furthermore, the "module" dependencies are not quite clear (ioutils,
Zend, TSRM is all a bit mixed up).
cc @nielsdos