Commit 0401fb3
[fileinfo] Hide libmagic dynamic symbols
When libphp.so (from the embed SAPI, or the apache module) is loaded
by another project that already uses libmagic, the symbols from the
two copies of libmagic...
$ objdump -TC ./libs/libphp.so | grep '\smagic_'
00000000002b2754 g DF .text 0000000000000034 Base magic_compile
00000000002b25fe g DF .text 0000000000000024 Base magic_open
00000000002b27f0 g DF .text 0000000000000034 Base magic_descriptor
00000000002b2720 g DF .text 0000000000000034 Base magic_load
00000000002b2c1a g DF .text 0000000000000032 Base magic_setflags
00000000002b27bc g DF .text 0000000000000034 Base magic_list
00000000002b2c62 g DF .text 0000000000000206 Base magic_setparam
00000000002b2bf4 g DF .text 0000000000000026 Base magic_getflags
00000000002b2bbe g DF .text 0000000000000036 Base magic_errno
00000000002b2e68 g DF .text 00000000000001f4 Base magic_getparam
00000000002b2b14 g DF .text 000000000000006e Base magic_buffer
00000000002b2b82 g DF .text 000000000000003c Base magic_error
00000000002b2788 g DF .text 0000000000000034 Base magic_check
00000000002b2c4c g DF .text 0000000000000016 Base magic_version
00000000002b26fa g DF .text 0000000000000026 Base magic_close
00000000002b2858 g DF .text 0000000000000034 Base magic_stream
00000000002b2824 g DF .text 0000000000000034 Base magic_file
can clash. To see this, we (pointlessly) link libphp.so from the
embed SAPI into a small program using the system copy of libmagic:
$ gcc $(/usr/lib/php8.5/bin/php-config --includes) main.c \
-L/usr/lib/php8.5/lib -lphp -lmagic
$ LD_LIBRARY_PATH=/usr/lib/php8.5/lib ./a.out
Segmentation fault LD_LIBRARY_PATH=/usr/lib/php8.5/lib ./a.out
To avoid this, we modify the internal "file_public" macro used by
libmagic, so that (on platforms that support it) hidden visibility is
used instead of the default. Afterwards the objdump command above
produces no output, and the test program no longer sefaults.
Co-authored-by: Ilija Tovilo <ilija.tovilo@me.com>
PHP-bug: https://bugs.php.net/bug.php?id=66095
Gentoo-bug: https://bugs.gentoo.org/471682
Fixes #66095
Closes GH-214721 parent e4b3ffe commit 0401fb3
3 files changed
+21
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| |||
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
54 | | - | |
| 55 | + | |
55 | 56 | | |
56 | 57 | | |
57 | 58 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1727 | 1727 | | |
1728 | 1728 | | |
1729 | 1729 | | |
1730 | | - | |
| 1730 | + | |
1731 | 1731 | | |
1732 | 1732 | | |
1733 | 1733 | | |
| |||
1767 | 1767 | | |
1768 | 1768 | | |
1769 | 1769 | | |
| 1770 | + | |
| 1771 | + | |
| 1772 | + | |
| 1773 | + | |
| 1774 | + | |
| 1775 | + | |
| 1776 | + | |
| 1777 | + | |
| 1778 | + | |
| 1779 | + | |
| 1780 | + | |
| 1781 | + | |
| 1782 | + | |
| 1783 | + | |
| 1784 | + | |
1770 | 1785 | | |
1771 | 1786 | | |
1772 | 1787 | | |
| |||
3075 | 3090 | | |
3076 | 3091 | | |
3077 | 3092 | | |
3078 | | - | |
| 3093 | + | |
3079 | 3094 | | |
3080 | 3095 | | |
3081 | 3096 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | | - | |
| 105 | + | |
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
110 | | - | |
| 110 | + | |
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
| |||
0 commit comments