Bug #66095 [Com]: Bundled libmagic has public symbols and conflicts with system libmagic
| From: | rossi dot f at inwind dot it | Date: | Sun, 28 Dec 2014 14:01:14 +0000 |
| Subject: | Bug #66095 [Com]: Bundled libmagic has public symbols and conflicts with system libmagic | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-189242@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=66095&edit=1
ID: 66095
Comment by: rossi dot f at inwind dot it
Reported by: vitalif at mail dot ru
Summary: Bundled libmagic has public symbols and conflicts
with system libmagic
Status: Open
Type: Bug
Package: Filesystem function related
Operating System: Linux
PHP Version: 5.5.6
Block user comment: N
Private report: N
New Comment:
I cannot find a way to upload the full log, here is a short piece:
ext/fileinfo/libmagic/.libs/apprentice.o:(.rodata+0x0): multiple definition of
`php_magic_database'
ext/fileinfo/.libs/fileinfo.o:(.rodata+0xe00): first defined here
ext/fileinfo/libmagic/.libs/apprentice.o:(.rodata+0x27c590): multiple definition of
`file_nnames'
ext/fileinfo/.libs/fileinfo.o:(.rodata+0x27d390): first defined here
ext/fileinfo/libmagic/.libs/apprentice.o:(.rodata+0x27c598): multiple definition of
`file_nformats'
ext/fileinfo/.libs/fileinfo.o:(.rodata+0x27d398): first defined here
ext/fileinfo/libmagic/.libs/cdf.o: In function `cdf_tole2':
/var/tmp/portage/dev-lang/php-5.5.20/work/sapis-build/cli/ext/fileinfo/libmagic/cdf.c:159: multiple
definition of `cdf_tole2'
ext/fileinfo/.libs/fileinfo.o:/var/tmp/portage/dev-lang/php-5.5.20/work/sapis-build/cli/ext/fileinfo/libmagic/cdf.c:159:
first defined here
ext/fileinfo/libmagic/.libs/cdf.o: In function `cdf_tole4':
/var/tmp/portage/dev-lang/php-5.5.20/work/sapis-build/cli/ext/fileinfo/libmagic/cdf.c:165: multiple
definition of `cdf_tole4'
ext/fileinfo/.libs/fileinfo.o:/var/tmp/portage/dev-lang/php-5.5.20/work/sapis-build/cli/ext/fileinfo/libmagic/cdf.c:165:
first defined here
ext/fileinfo/libmagic/.libs/cdf.o: In function `cdf_tole8':
/var/tmp/portage/dev-lang/php-5.5.20/work/sapis-build/cli/ext/fileinfo/libmagic/cdf.c:171: multiple
definition of `cdf_tole8'
ext/fileinfo/.libs/fileinfo.o:/var/tmp/portage/dev-lang/php-5.5.20/work/sapis-build/cli/ext/fileinfo/libmagic/cdf.c:171:
first defined here
ext/fileinfo/libmagic/.libs/cdf.o: In function `cdf_swap_header':
/var/tmp/portage/dev-lang/php-5.5.20/work/sapis-build/cli/ext/fileinfo/libmagic/cdf.c:179: multiple
definition of `cdf_swap_header'
ext/fileinfo/.libs/fileinfo.o:/var/tmp/portage/dev-lang/php-5.5.20/work/sapis-build/cli/ext/fileinfo/libmagic/cdf.c:179:
first defined here
ext/fileinfo/libmagic/.libs/cdf.o: In function `memcpy':
/usr/include/bits/string3.h:51: multiple definition of `cdf_unpack_header'
ext/fileinfo/.libs/fileinfo.o:/usr/include/bits/string3.h:51: first defined here
ext/fileinfo/libmagic/.libs/cdf.o: In function `cdf_swap_dir':
/var/tmp/portage/dev-lang/php-5.5.20/work/sapis-build/cli/ext/fileinfo/libmagic/cdf.c:232: multiple
definition of `cdf_swap_dir'
ext/fileinfo/.libs/fileinfo.o:/var/tmp/portage/dev-lang/php-5.5.20/work/sapis-build/cli/ext/fileinfo/libmagic/cdf.c:232:
first defined here
ext/fileinfo/libmagic/.libs/cdf.o: In function `cdf_swap_class':
/var/tmp/portage/dev-lang/php-5.5.20/work/sapis-build/cli/ext/fileinfo/libmagic/cdf.c:248: multiple
definition of `cdf_swap_class'
ext/fileinfo/.libs/fileinfo.o:/var/tmp/portage/dev-lang/php-5.5.20/work/sapis-build/cli/ext/fileinfo/libmagic/cdf.c:248:
first defined here
ext/fileinfo/libmagic/.libs/cdf.o: In function `memcpy':
/usr/include/bits/string3.h:51: multiple definition of `cdf_unpack_dir'
ext/fileinfo/.libs/fileinfo.o:/usr/include/bits/string3.h:51: first defined here
ext/fileinfo/libmagic/.libs/cdf.o: In function `cdf_read_header':
/var/tmp/portage/dev-lang/php-5.5.20/work/sapis-build/cli/ext/fileinfo/libmagic/cdf.c:322: multiple
definition of `cdf_read_header'
ext/fileinfo/.libs/fileinfo.o:/var/tmp/portage/dev-lang/php-5.5.20/work/sapis-build/cli/ext/fileinfo/libmagic/cdf.c:322:
first defined here
ext/fileinfo/libmagic/.libs/cdf.o: In function `cdf_read_sector':
/var/tmp/portage/dev-lang/php-5.5.20/work/sapis-build/cli/ext/fileinfo/libmagic/cdf.c:356: multiple
definition of `cdf_read_sector'
ext/fileinfo/.libs/fileinfo.o:/var/tmp/portage/dev-lang/php-5.5.20/work/sapis-build/cli/ext/fileinfo/libmagic/cdf.c:356:
first defined here
ext/fileinfo/libmagic/.libs/cdf.o: In function `cdf_read_short_sector':
/var/tmp/portage/dev-lang/php-5.5.20/work/sapis-build/cli/ext/fileinfo/libmagic/cdf.c:366: multiple
definition of `cdf_read_short_sector'
ext/fileinfo/.libs/fileinfo.o:/var/tmp/portage/dev-lang/php-5.5.20/work/sapis-build/cli/ext/fileinfo/libmagic/cdf.c:366:
first defined here
ext/fileinfo/libmagic/.libs/cdf.o: In function `cdf_read_sat':
/var/tmp/portage/dev-lang/php-5.5.20/work/sapis-build/cli/ext/fileinfo/libmagic/cdf.c:386: multiple
definition of `cdf_read_sat'
ext/fileinfo/.libs/fileinfo.o:/var/tmp/portage/dev-lang/php-5.5.20/work/sapis-build/cli/ext/fileinfo/libmagic/cdf.c:386:
first defined here
ext/fileinfo/libmagic/.libs/cdf.o: In function `cdf_count_chain':
/var/tmp/portage/dev-lang/php-5.5.20/work/sapis-build/cli/ext/fileinfo/libmagic/cdf.c:473: multiple
definition of `cdf_count_chain'
ext/fileinfo/.libs/fileinfo.o:/var/tmp/portage/dev-lang/php-5.5.20/work/sapis-build/cli/ext/fileinfo/libmagic/cdf.c:473:
first defined here
ext/fileinfo/libmagic/.libs/cdf.o: In function `cdf_read_long_sector_chain':
/var/tmp/portage/dev-lang/php-5.5.20/work/sapis-build/cli/ext/fileinfo/libmagic/cdf.c:498: multiple
definition of `cdf_read_long_sector_chain'
ext/fileinfo/.libs/fileinfo.o:/var/tmp/portage/dev-lang/php-5.5.20/work/sapis-build/cli/ext/fileinfo/libmagic/cdf.c:498:
first defined here
ext/fileinfo/libmagic/.libs/cdf.o: In function `cdf_read_short_sector_chain':
/var/tmp/portage/dev-lang/php-5.5.20/work/sapis-build/cli/ext/fileinfo/libmagic/cdf.c:545: multiple
definition of `cdf_read_short_sector_chain'
ext/fileinfo/.libs/fileinfo.o:/var/tmp/portage/dev-lang/php-5.5.20/work/sapis-build/cli/ext/fileinfo/libmagic/cdf.c:545:
first defined here
ext/fileinfo/libmagic/.libs/cdf.o: In function `cdf_read_sector_chain':
/var/tmp/portage/dev-lang/php-5.5.20/work/sapis-build/cli/ext/fileinfo/libmagic/cdf.c:587: multiple
definition of `cdf_read_sector_chain'
ext/fileinfo/.libs/fileinfo.o:/var/tmp/portage/dev-lang/php-5.5.20/work/sapis-build/cli/ext/fileinfo/libmagic/cdf.c:587:
first defined here
ext/fileinfo/libmagic/.libs/cdf.o: In function `cdf_read_dir':
/var/tmp/portage/dev-lang/php-5.5.20/work/sapis-build/cli/ext/fileinfo/libmagic/cdf.c:599: multiple
definition of `cdf_read_dir'
ext/fileinfo/.libs/fileinfo.o:/var/tmp/portage/dev-lang/php-5.5.20/work/sapis-build/cli/ext/fileinfo/libmagic/cdf.c:599:
first defined here
ext/fileinfo/libmagic/.libs/cdf.o: In function `cdf_read_ssat':
/var/tmp/portage/dev-lang/php-5.5.20/work/sapis-build/cli/ext/fileinfo/libmagic/cdf.c:653: multiple
definition of `cdf_read_ssat'
ext/fileinfo/.libs/fileinfo.o:/var/tmp/portage/dev-lang/php-5.5.20/work/sapis-build/cli/ext/fileinfo/libmagic/cdf.c:653:
first defined here
ext/fileinfo/libmagic/.libs/cdf.o: In function `cdf_read_short_stream':
/var/tmp/portage/dev-lang/php-5.5.20/work/sapis-build/cli/ext/fileinfo/libmagic/cdf.c:699: multiple
definition of `cdf_read_short_stream'
ext/fileinfo/.libs/fileinfo.o:/var/tmp/portage/dev-lang/php-5.5.20/work/sapis-build/cli/ext/fileinfo/libmagic/cdf.c:699:
first defined here
ext/fileinfo/libmagic/.libs/cdf.o: In function `cdf_read_summary_info':
/var/tmp/portage/dev-lang/php-5.5.20/work/sapis-build/cli/ext/fileinfo/libmagic/cdf.c:734: multiple
definition of `cdf_read_summary_info'
ext/fileinfo/.libs/fileinfo.o:/var/tmp/portage/dev-lang/php-5.5.20/work/sapis-build/cli/ext/fileinfo/libmagic/cdf.c:734:
first defined here
ext/fileinfo/libmagic/.libs/cdf.o: In function `cdf_read_property_info':
/var/tmp/portage/dev-lang/php-5.5.20/work/sapis-build/cli/ext/fileinfo/libmagic/cdf.c:758: multiple
definition of `cdf_read_property_info'
ext/fileinfo/.libs/fileinfo.o:/var/tmp/portage/dev-lang/php-5.5.20/work/sapis-build/cli/ext/fileinfo/libmagic/cdf.c:758:
first defined here
ext/fileinfo/libmagic/.libs/cdf.o: In function `cdf_unpack_summary_info':
/var/tmp/portage/dev-lang/php-5.5.20/work/sapis-build/cli/ext/fileinfo/libmagic/cdf.c:957: multiple
definition of `cdf_unpack_summary_info'
ext/fileinfo/.libs/fileinfo.o:/var/tmp/portage/dev-lang/php-5.5.20/work/sapis-build/cli/ext/fileinfo/libmagic/cdf.c:957:
first defined here
ext/fileinfo/libmagic/.libs/cdf.o: In function `cdf_print_classid':
/var/tmp/portage/dev-lang/php-5.5.20/work/sapis-build/cli/ext/fileinfo/libmagic/cdf.c:987: multiple
definition of `cdf_print_classid'
ext/fileinfo/.libs/fileinfo.o:/var/tmp/portage/dev-lang/php-5.5.20/work/sapis-build/cli/ext/fileinfo/libmagic/cdf.c:987:
first defined here
ext/fileinfo/libmagic/.libs/cdf.o: In function `cdf_print_property_name':
/var/tmp/portage/dev-lang/php-5.5.20/work/sapis-build/cli/ext/fileinfo/libmagic/cdf.c:1023: multiple
definition of `cdf_print_property_name'
ext/fileinfo/.libs/fileinfo.o:/var/tmp/portage/dev-lang/php-5.5.20/work/sapis-build/cli/ext/fileinfo/libmagic/cdf.c:1023:
first defined here
ext/fileinfo/libmagic/.libs/cdf.o: In function `cdf_print_elapsed_time':
/var/tmp/portage/dev-lang/php-5.5.20/work/sapis-build/cli/ext/fileinfo/libmagic/cdf.c:1034: multiple
definition of `cdf_print_elapsed_time'
ext/fileinfo/.libs/fileinfo.o:/var/tmp/portage/dev-lang/php-5.5.20/work/sapis-build/cli/ext/fileinfo/libmagic/cdf.c:1034:
first defined here
ext/fileinfo/libmagic/.libs/cdf_time.o: In function `cdf_timestamp_to_timespec':
/var/tmp/portage/dev-lang/php-5.5.20/work/sapis-build/cli/ext/fileinfo/libmagic/cdf_time.c:109:
multiple definition of `cdf_timestamp_to_timespec'
ext/fileinfo/.libs/fileinfo.o:/var/tmp/portage/dev-lang/php-5.5.20/work/sapis-build/cli/ext/fileinfo/libmagic/cdf_time.c:109:
first defined here
ext/fileinfo/libmagic/.libs/cdf_time.o: In function `cdf_timespec_to_timestamp':
/var/tmp/portage/dev-lang/php-5.5.20/work/sapis-build/cli/ext/fileinfo/libmagic/cdf_time.c:167:
multiple definition of `cdf_timespec_to_timestamp'
ext/fileinfo/.libs/fileinfo.o:/var/tmp/portage/dev-lang/php-5.5.20/work/sapis-build/cli/ext/fileinfo/libmagic/cdf_time.c:167:
first defined here
ext/fileinfo/libmagic/.libs/cdf_time.o: In function `cdf_ctime':
/var/tmp/portage/dev-lang/php-5.5.20/work/sapis-build/cli/ext/fileinfo/libmagic/cdf_time.c:171:
multiple definition of `cdf_ctime'
ext/fileinfo/.libs/fileinfo.o:/var/tmp/portage/dev-lang/php-5.5.20/work/sapis-build/cli/ext/fileinfo/libmagic/cdf_time.c:171:
first defined here
collect2: error: ld returned 1 exit status
Makefile:266: recipe for target 'sapi/cli/php' failed
make: *** [sapi/cli/php] Error 1
Previous Comments:
------------------------------------------------------------------------
[2014-12-28 13:55:06] rossi dot f at inwind dot it
First of all I'm experiencing the same problem with my system, I'm using PHP 5.5.20 and
apache 2.2.27 with an external libmagic (version 5.21). Up to now the only way to survive has been
to keep the system libmagic at version 5.11 but this has implications on the secuiry!
Is there any PHP developer thinking about how to solve this issue?
I have tried to apply the patch here proposed but it doesn't seem to work because I get errors
when compiling the code, see the attached log.
------------------------------------------------------------------------
[2014-02-25 19:24:10] devurandom at gmx dot net
See-Also: https://bugs.php.net/bug.php?id=54241
------------------------------------------------------------------------
[2014-02-25 19:16:49] devurandom at gmx dot net
I can reproduce this using PHP 5.5.9 on Apache 2.4.7.
See-Also: https://github.com/jappix/jappix/issues/417
------------------------------------------------------------------------
[2013-11-14 13:58:58] vitalif at mail dot ru
Description:
------------
In the PHP fileinfo extension, there is a bundled libmagic with public symbols.
So when the fileinfo extension is loaded (either as a shared object or when built into PHP itself) -
it can conflict with system libmagic.
The conflict appears when you have different system libmagic version, and when you load PHP module
into Apache along with some other Apache module that uses libmagic, for example - mod_dav_svn
(Subversion DAV server). The result depends on the loading order:
* If libphp5.so (or fileinfo.so) is loaded first, then Subversion gets incorrect libmagic symbols
and crashes
* If mod_dav_svn is loaded first, then PHP fileinfo gets incorrect libmagic symbols and also crashes
The bundled extension should have ALL libmagic symbols declared as static. It can be achieved via
overriding 'public/protected' macros in libmagic code and including all libmagic sources
into fileinfo.c instead of compiling and linking them separately. (See the attached patch)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=66095&edit=1