Skip to content

Commit a9e45bc

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fix #78296: is_file fails to detect file
2 parents 4ff242a + bb735c9 commit a9e45bc

File tree

4 files changed

+37
-2
lines changed

4 files changed

+37
-2
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ PHP NEWS
88
exception). (Nikita)
99
. Fixed bug #78868 (Calling __autoload() with incorrect EG(fake_scope) value).
1010
(Antony Dovgal, Dmitry)
11+
. Fixed bug #78296 (is_file fails to detect file). (cmb)
1112

1213
- GD:
1314
. Fixed bug #78849 (GD build broken with -D SIGNED_COMPARE_SLOW). (cmb)

ext/standard/tests/file/bug78296.phpt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
Bug #78296 (is_file fails to detect file)
3+
--FILE--
4+
<?php
5+
$dir = str_pad(__DIR__ . '/bug78296', 250, '_');
6+
var_dump(mkdir($dir));
7+
var_dump(is_dir($dir));
8+
?>
9+
--EXPECT--
10+
bool(true)
11+
bool(true)
12+
--CLEAN--
13+
<?php
14+
$dir = str_pad(__DIR__ . '/bug78296', 250, '_');
15+
rmdir($dir);
16+
?>

win32/ioutil.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,13 +322,23 @@ PW32IO int php_win32_ioutil_mkdir_w(const wchar_t *path, mode_t mode)
322322

323323
if (!PHP_WIN32_IOUTIL_IS_LONG_PATHW(tmp, path_len)) {
324324
wchar_t *_tmp = (wchar_t *) malloc((path_len + PHP_WIN32_IOUTIL_LONG_PATH_PREFIX_LENW + 1) * sizeof(wchar_t));
325+
wchar_t *src, *dst;
325326
if (!_tmp) {
326327
SET_ERRNO_FROM_WIN32_CODE(ERROR_NOT_ENOUGH_MEMORY);
327328
free(tmp);
328329
return -1;
329330
}
330331
memmove(_tmp, PHP_WIN32_IOUTIL_LONG_PATH_PREFIXW, PHP_WIN32_IOUTIL_LONG_PATH_PREFIX_LENW * sizeof(wchar_t));
331-
memmove(_tmp+PHP_WIN32_IOUTIL_LONG_PATH_PREFIX_LENW, tmp, path_len * sizeof(wchar_t));
332+
src = tmp;
333+
dst = _tmp + PHP_WIN32_IOUTIL_LONG_PATH_PREFIX_LENW;
334+
while (src < tmp + path_len) {
335+
if (*src == PHP_WIN32_IOUTIL_FW_SLASHW) {
336+
*dst++ = PHP_WIN32_IOUTIL_DEFAULT_SLASHW;
337+
src++;
338+
} else {
339+
*dst++ = *src++;
340+
}
341+
}
332342
path_len += PHP_WIN32_IOUTIL_LONG_PATH_PREFIX_LENW;
333343
_tmp[path_len] = L'\0';
334344
free(tmp);

win32/ioutil.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,16 @@ __forceinline static wchar_t *php_win32_ioutil_conv_any_to_w(const char* in, siz
220220
memmove(ret, mb, mb_len * sizeof(wchar_t));
221221
ret[mb_len] = L'\0';
222222
} else {
223+
wchar_t *src = mb, *dst = ret + PHP_WIN32_IOUTIL_LONG_PATH_PREFIX_LENW;
223224
memmove(ret, PHP_WIN32_IOUTIL_LONG_PATH_PREFIXW, PHP_WIN32_IOUTIL_LONG_PATH_PREFIX_LENW * sizeof(wchar_t));
224-
memmove(ret+PHP_WIN32_IOUTIL_LONG_PATH_PREFIX_LENW, mb, mb_len * sizeof(wchar_t));
225+
while (src < mb + mb_len) {
226+
if (*src == PHP_WIN32_IOUTIL_FW_SLASHW) {
227+
*dst++ = PHP_WIN32_IOUTIL_DEFAULT_SLASHW;
228+
src++;
229+
} else {
230+
*dst++ = *src++;
231+
}
232+
}
225233
ret[mb_len + PHP_WIN32_IOUTIL_LONG_PATH_PREFIX_LENW] = L'\0';
226234

227235
mb_len += PHP_WIN32_IOUTIL_LONG_PATH_PREFIX_LENW;

0 commit comments

Comments
 (0)