Edit report at https://bugs.php.net/bug.php?id=62444&edit=1

 ID:                 62444
 Updated by:         larue...@php.net
 Reported by:        sergio dot nalin at gmail dot com
 Summary:            Handle leak in is_readable
 Status:             Closed
 Type:               Bug
 Package:            Filesystem function related
 Operating System:   Win 7 64bit
 PHP Version:        5.3.14
 Assigned To:        pajoye
 Block user comment: N
 Private report:     N

 New Comment:

according to the msdn, the fix is okey to me, merged.

" Remarks
Tokens with the anonymous impersonation level cannot be opened.
Close the access token handle returned through the TokenHandle parameter by 
calling CloseHandle. "

http://msdn.microsoft.com/en-us/library/windows/desktop/aa379296(v=vs.85).aspx


Previous Comments:
------------------------------------------------------------------------
[2012-11-02 10:58:28] larue...@php.net

Automatic comment on behalf of laruence
Revision: 
http://git.php.net/?p=php-src.git;a=commit;h=3fe3029ecb9f121eb6f535970d5cd18ecc8373a6
Log: Fixed bug #62444 (Handle leak in is_readable on windows).

------------------------------------------------------------------------
[2012-11-02 10:56:15] larue...@php.net

Automatic comment on behalf of laruence
Revision: 
http://git.php.net/?p=php-src.git;a=commit;h=3fe3029ecb9f121eb6f535970d5cd18ecc8373a6
Log: Fixed bug #62444 (Handle leak in is_readable on windows).

------------------------------------------------------------------------
[2012-11-02 10:53:26] larue...@php.net

Automatic comment on behalf of laruence
Revision: 
http://git.php.net/?p=php-src.git;a=commit;h=3fe3029ecb9f121eb6f535970d5cd18ecc8373a6
Log: Fixed bug #62444 (Handle leak in is_readable on windows).

------------------------------------------------------------------------
[2012-11-02 08:57:38] krazyest at seznam dot cz

The problem is in TSRM\tsrm_win32.c in function

TSRM_API int tsrm_win32_access(const char *pathname, int mode TSRMLS_DC)

A local variable 

        HANDLE thread_token;

is being initialized by this call

                if(!OpenThreadToken(GetCurrentThread(), TOKEN_ALL_ACCESS, TRUE, 
&thread_token)) {

which is likely to succeed, but even if it does not there is another call

                                if (!OpenProcessToken(GetCurrentProcess(), 
TOKEN_ALL_ACCESS, &thread_token)) {

that creates the handle.  

However, no CloseHandle is called, which causes the handle to leak. 

We need to change the code like this

        HANDLE thread_token;
->      
        HANDLE thread_token=NULL;



Finished:
                if(real_path != NULL) {
                        free(real_path);
                        real_path = NULL;
                }
->
Finished:
                if (thread_token) CloseHandle(thread_token);

                if(real_path != NULL) {
                        free(real_path);
                        real_path = NULL;
                }

------------------------------------------------------------------------
[2012-10-31 22:21:54] vseticka dot martin at gmail dot com

Is there any progress? This issue makes PHP really hard to use on Windows.

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=62444


-- 
Edit this bug report at https://bugs.php.net/bug.php?id=62444&edit=1

Reply via email to