From: Anatol Belski Date: Wed, 8 Nov 2017 10:54:18 +0000 (+0100) Subject: Merge branch 'PHP-7.0' into PHP-7.1 X-Git-Tag: php-7.1.13RC1~47 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d36e793c936b40b6b5adba8433bf067de819aae5;p=php Merge branch 'PHP-7.0' into PHP-7.1 * PHP-7.0: Fixed #75384 PHP seems incompatible with OneDrive files on demand Fixed ext/date tests due to changes in Olson database --- d36e793c936b40b6b5adba8433bf067de819aae5 diff --cc Zend/zend_virtual_cwd.c index 2fa12f8180,b6b798eaca..5ce3354e9a --- a/Zend/zend_virtual_cwd.c +++ b/Zend/zend_virtual_cwd.c @@@ -936,10 -921,8 +949,10 @@@ static int tsrm_realpath_r(char *path, return -1; } - hLink = CreateFileW(pathw, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_FLAG_OPEN_REPARSE_POINT|FILE_FLAG_BACKUP_SEMANTICS, NULL); - hLink = CreateFile(path, 0, 0, NULL, OPEN_EXISTING, FILE_FLAG_OPEN_REPARSE_POINT|FILE_FLAG_BACKUP_SEMANTICS, NULL); ++ hLink = CreateFileW(pathw, 0, 0, NULL, OPEN_EXISTING, FILE_FLAG_OPEN_REPARSE_POINT|FILE_FLAG_BACKUP_SEMANTICS, NULL); if(hLink == INVALID_HANDLE_VALUE) { + free_alloca(tmp, use_heap); + FREE_PATHW() return -1; } @@@ -997,47 -968,34 +1010,51 @@@ else if(pbuffer->ReparseTag == IO_REPARSE_TAG_MOUNT_POINT) { isabsolute = 1; reparsetarget = pbuffer->MountPointReparseBuffer.ReparseTarget; - printname_len = pbuffer->MountPointReparseBuffer.PrintNameLength / sizeof(WCHAR); - if (!WideCharToMultiByte(CP_THREAD_ACP, 0, - reparsetarget + pbuffer->MountPointReparseBuffer.PrintNameOffset / sizeof(WCHAR), - printname_len + 1, - printname, MAX_PATH, NULL, NULL - )) { +#if VIRTUAL_CWD_DEBUG + printname = php_win32_ioutil_w_to_any(reparsetarget + pbuffer->MountPointReparseBuffer.PrintNameOffset / sizeof(WCHAR)); + if (!printname) { free_alloca(pbuffer, use_heap_large); + free_alloca(tmp, use_heap); + FREE_PATHW() return -1; - }; - printname[pbuffer->MountPointReparseBuffer.PrintNameLength / sizeof(WCHAR)] = 0; + } +#endif + substitutename_len = pbuffer->MountPointReparseBuffer.SubstituteNameLength / sizeof(WCHAR); - if (!WideCharToMultiByte(CP_THREAD_ACP, 0, - reparsetarget + pbuffer->MountPointReparseBuffer.SubstituteNameOffset / sizeof(WCHAR), - substitutename_len + 1, - substitutename, MAX_PATH, NULL, NULL - )) { + if (substitutename_len >= MAXPATHLEN) { free_alloca(pbuffer, use_heap_large); + free_alloca(tmp, use_heap); + FREE_PATHW() return -1; - }; - substitutename[substitutename_len] = 0; + } + memmove(tmpsubstname, reparsetarget + pbuffer->MountPointReparseBuffer.SubstituteNameOffset / sizeof(WCHAR), pbuffer->MountPointReparseBuffer.SubstituteNameLength); + tmpsubstname[substitutename_len] = L'\0'; + substitutename = php_win32_cp_conv_w_to_any(tmpsubstname, substitutename_len, &substitutename_len); + if (!substitutename || substitutename_len >= MAXPATHLEN) { + free_alloca(pbuffer, use_heap_large); + free_alloca(tmp, use_heap); + free(substitutename); +#if VIRTUAL_CWD_DEBUG + free(printname); +#endif + FREE_PATHW() + return -1; + } } - else if (pbuffer->ReparseTag == IO_REPARSE_TAG_DEDUP) { + else if (pbuffer->ReparseTag == IO_REPARSE_TAG_DEDUP || + /* Starting with 1709. */ + (pbuffer->ReparseTag & IO_REPARSE_TAG_CLOUD_MASK) != 0 && 0x90001018L != pbuffer->ReparseTag || + IO_REPARSE_TAG_CLOUD == pbuffer->ReparseTag || + IO_REPARSE_TAG_ONEDRIVE == pbuffer->ReparseTag) { isabsolute = 1; + substitutename = malloc((len + 1) * sizeof(char)); + if (!substitutename) { + free_alloca(pbuffer, use_heap_large); + free_alloca(tmp, use_heap); + FREE_PATHW() + return -1; + } memcpy(substitutename, path, len + 1); substitutename_len = len; } else {