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

 ID:                 63248
 Comment by:         a...@php.net
 Reported by:        a...@php.net
 Summary:            ext\fileinfo\tests\bug61964.phpt fails
 Status:             Open
 Type:               Bug
 Package:            *General Issues
 Operating System:   Windows
 PHP Version:        5.4Git-2012-10-09 (Git)
 Block user comment: N
 Private report:     N

 New Comment:

Updated the patch, using the PHPs readdir implementation win32/readdir.c 
instead of reimlementing it :)


Previous Comments:
------------------------------------------------------------------------
[2012-10-11 15:42:01] a...@php.net

The following patch has been added/updated:

Patch Name: bug63248.patch
Revision:   1349970121
URL:        
https://bugs.php.net/patch-display.php?bug=63248&patch=bug63248.patch&revision=1349970121

------------------------------------------------------------------------
[2012-10-10 18:02:46] a...@php.net

The issue is the following - when a directory is given as a magic path, 
libmagic looks for files inside it and tries to load all the files as magic 
files. Under windows there are two wrong points

- libmagic tries to get a directory handle
- libmagic uses opendir, readdir and so on which doesn't well on windows

The patch prevents libmagic from opening a directory and uses FindNextFile from 
the windows API to iterate dirs.

After applying this patch there are two tests failing

ext\fileinfo\tests\finfo_file_regex-win32.phpt
ext\fileinfo\tests\finfo_open_error-win32.phpt

But, the corresponding non win32 tests pass. Different behaviour of that two 
win32 tests seems co be caused because of the bug in this ticket, so then they 
could be kicked after the patch was applied.

------------------------------------------------------------------------
[2012-10-10 17:51:00] a...@php.net

The following patch has been added/updated:

Patch Name: bug63248.patch
Revision:   1349891460
URL:        
https://bugs.php.net/patch-display.php?bug=63248&patch=bug63248.patch&revision=1349891460

------------------------------------------------------------------------
[2012-10-09 14:45:05] a...@php.net

Description:
------------
As one can see from the diff, there a permissions warning. Tries to set the 
full permissions didn't work, so I've debugged it. Here is the VS backtrace

        php_fileinfo.dll!apprentice_map(magic_set * ms, magic * * magicp, 
unsigned int * nmagicp, const char * fn) Line 2219    C
        php_fileinfo.dll!apprentice_1(magic_set * ms, const char * fn, int 
action, mlist * mlist) Line 271      C
        php_fileinfo.dll!file_apprentice(magic_set * ms, const char * fn, int 
action) Line 369  C
        php_fileinfo.dll!magic_load(magic_set * ms, const char * magicfile) 
Line 308    C
        php_fileinfo.dll!zif_finfo_open(int ht, _zval_struct * return_value, 
_zval_struct * * return_value_ptr, _zval_struct * this_ptr, int 
return_value_used, void * * * tsrm_ls) Line 345    C
        php5ts_debug.dll!zend_do_fcall_common_helper_SPEC(_zend_execute_data * 
execute_data, void * * * tsrm_ls) Line 642       C
        php5ts_debug.dll!ZEND_DO_FCALL_SPEC_CONST_HANDLER(_zend_execute_data * 
execute_data, void * * * tsrm_ls) Line 2236      C
        php5ts_debug.dll!execute(_zend_op_array * op_array, void * * * tsrm_ls) 
Line 410        C
        php5ts_debug.dll!zend_execute_scriapts(int type, void * * * tsrm_ls, 
_zval_struct * * retval, int file_count, ...) Line 1309    C
        php5ts_debug.dll!php_execute_script(_zend_file_handle * primary_file, 
void * * * tsrm_ls) Line 2482     C
        php.exe!do_cli(int argc, char * * argv, void * * * tsrm_ls) Line 988    
C
        php.exe!main(int argc, char * * argv) Line 1364 C
        php.exe!__tmainCRTStartup() Line 582    C

The warning is produced by the finfo_open() when an existing directory is 
passed as a magic path.

Expected result:
----------------
Test pass

Actual result:
--------------
003+ Warning: 
finfo_open(C:\php-sdk\php54\vc9\x86\php-src\ext\fileinfo\tests\test-folder): 
failed to open stream: Permission denied in 
C:\php-sdk\php54\vc9\x86\php-src\ext\fileinfo\tests\bug61964.php on line 16
006- Notice: finfo_open(): Warning: offset `string' invalid in %sbug61964.php 
on line %d
007-
008- Notice: finfo_open(): Warning: offset ` Core' invalid in %sbug61964.php on 
line %d
008+ Warning: 
finfo_open(C:\php-sdk\php54\vc9\x86\php-src\ext\fileinfo\tests\test-folder): 
failed to open stream: Permission denied in 
C:\php-sdk\php54\vc9\x86\php-src\ext\fileinfo\tests\bug61964.php on line 30
009+ DONE: testing dir with files
010+ ===DONE===
009-
010- Notice: finfo_open(): Warning: type `Core' invalid in %sbug61964.php on 
line %d
011-
012- Notice: finfo_open(): Warning: offset `a' invalid in %sbug61964.php on 
line %d
013-
014- Notice: finfo_open(): Warning: type `a' invalid in %sbug61964.php on line 
%d
015-
016- Notice: finfo_open(): Warning: offset `b' invalid in %sbug61964.php on 
line %d
017-
018- Notice: finfo_open(): Warning: type `b' invalid in %sbug61964.php on line 
%d
019-
020- Warning: finfo_open(): Failed to load magic database at '%stest-folder'. 
in %sbug61964.php on line %d
021- DONE: testing dir with files
022- ===DONE===


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



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

Reply via email to