/[packages]/cauldron/pcre/current/SOURCES/pcre-pcreposix-glibc-conflict.patch
ViewVC logotype

Contents of /cauldron/pcre/current/SOURCES/pcre-pcreposix-glibc-conflict.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 821978 - (show annotations) (download)
Tue May 12 23:10:16 2015 UTC (8 years, 11 months ago) by neoclust
File size: 4041 byte(s)
New version
   Fixes CVE-2015-2325 and CVE-2015-2326

1 the goal of the patch is to fix the following problem:
2
3 "Dan Nicholson" <dbn.lists@gmail.com> writes:
4
5 [...]
6
7 > And now I've come upon this old thread:
8 >
9 > http://rpm5.org/community/rpm-devel/1554.html
10 >
11 > This is definitely the problem. When --as-needed is used, libc is
12 > bound first to tmire, causing regcomp and friends to be resolved
13 > through libc rather than libpcreposix.
14
15 the symbol conflict is a mess. pcreposix better be fixed
16 (http://rpm5.org/community/rpm-devel/1562.html)
17
18 it's hard to beat libc... here is what happens:
19
20 % echo 'int f() { regcomp(); }' > liba.c
21 % gcc -shared -o liba.so liba.c -lpcreposix
22 % ldd liba.so
23 libpcreposix.so.0 => /usr/lib/libpcreposix.so.0 (0xb7f76000)
24 libc.so.6 => /lib/i686/libc.so.6 (0xb7e28000)
25 libpcre.so.0 => /lib/libpcre.so.0 (0xb7e00000)
26 % gcc -shared -o liba_.so liba.so
27 % LD_LIBRARY_PATH=`pwd` ldd liba_.so
28 liba.so => /tmp/liba.so (0xb7f44000)
29 libc.so.6 => /lib/i686/libc.so.6 (0xb7de2000)
30 libpcreposix.so.0 => /usr/lib/libpcreposix.so.0 (0xb7de0000)
31 libpcre.so.0 => /lib/libpcre.so.0 (0xb7db8000)
32
33 one can see -lc has been added. confirmed by:
34
35 % gcc -nostdlib -shared -o liba_.so liba.so
36 % LD_LIBRARY_PATH=`pwd` ldd liba_.so
37 liba.so => /tmp/liba.so (0xb7f19000)
38 libpcreposix.so.0 => /usr/lib/libpcreposix.so.0 (0xb7f03000)
39 libc.so.6 => /lib/i686/libc.so.6 (0xb7db5000)
40 libpcre.so.0 => /lib/libpcre.so.0 (0xb7d8d000)
41
42 but using -nostdlib is harder when building a binary... hence the need
43 to force -lpcreposix at each linking steps:
44
45 % gcc -shared -o liba_.so liba.so -lpcreposix
46 % LD_LIBRARY_PATH=`pwd` ldd liba_.so
47 liba.so => /tmp/liba.so (0xb7f9f000)
48 libpcreposix.so.0 => /usr/lib/libpcreposix.so.0 (0xb7f89000)
49 libc.so.6 => /lib/i686/libc.so.6 (0xb7e3b000)
50 libpcre.so.0 => /lib/libpcre.so.0 (0xb7e13000)
51
52
53 which defeats the idea of DSO which should handle their deps themselves.
54 and such hacks do not play well with --as-needed:
55
56 export LD_LIBRARY_PATH=/tmp
57 cd /tmp
58 echo 'int f() { printf("fa "); }' > liba.c
59 echo 'int f() { printf("fb "); }' > libb.c
60 echo 'int g() { }' >> libb.c
61 echo 'int h() { f(); g(); }' > libx.c
62 echo 'main() { h(); g(); printf("\n"); }' > t.c
63 gcc -o liba.so -shared liba.c
64 gcc -o libb.so -shared libb.c
65 gcc -o libx.so -shared libx.c -L. -la -lb
66 gcc t.c -L. -lx ; ./a.out # fb
67 gcc t.c -L. -lx -la; ./a.out # fa
68 gcc -Wl,--as-needed t.c -L. -lx -la; ./a.out # fb
69
70
71 i wonder if ld could have a warning to detect about multiple symbols
72 in DSO and so tell about possible issues with --as-needed.
73
74
75 diff --git a/configure.ac b/configure.ac
76 index 38d1dba..d423f0f 100644
77 --- a/configure.ac
78 +++ b/configure.ac
79 @@ -20,7 +20,7 @@ m4_define(pcre_date, [2015-04-28])
80 m4_define(libpcre_version, [3:5:2])
81 m4_define(libpcre16_version, [2:5:2])
82 m4_define(libpcre32_version, [0:5:0])
83 -m4_define(libpcreposix_version, [0:3:0])
84 +m4_define(libpcreposix_version, [1:0:0])
85 m4_define(libpcrecpp_version, [0:1:0])
86
87 AC_PREREQ(2.57)
88 diff --git a/pcreposix.h b/pcreposix.h
89 index 6424a74..b869da5 100644
90 --- a/pcreposix.h
91 +++ b/pcreposix.h
92 @@ -132,15 +132,19 @@ file. */
93 #endif
94
95 /* The functions */
96 -
97 -PCREPOSIX_EXP_DECL int regcomp(regex_t *, const char *, int);
98 -PCREPOSIX_EXP_DECL int regexec(const regex_t *, const char *, size_t,
99 +PCREPOSIX_EXP_DECL int pcreposix_regcomp(regex_t *, const char *, int);
100 +PCREPOSIX_EXP_DECL int pcreposix_regexec(const regex_t *, const char *, size_t,
101 regmatch_t *, int);
102 -PCREPOSIX_EXP_DECL size_t regerror(int, const regex_t *, char *, size_t);
103 -PCREPOSIX_EXP_DECL void regfree(regex_t *);
104 +PCREPOSIX_EXP_DECL size_t pcreposix_regerror(int, const regex_t *, char *, size_t);
105 +PCREPOSIX_EXP_DECL void pcreposix_regfree(regex_t *);
106
107 #ifdef __cplusplus
108 } /* extern "C" */
109 #endif
110
111 +#define regcomp pcreposix_regcomp
112 +#define regexec pcreposix_regexec
113 +#define regerror pcreposix_regerror
114 +#define regfree pcreposix_regfree
115 +
116 #endif /* End of pcreposix.h */

  ViewVC Help
Powered by ViewVC 1.1.30