ebtables: fix segmentation fault due to uninitialized extension data
[openwrt/openwrt.git] / package / network / utils / ebtables / patches / 200-fix-extension-init.patch
1 --- a/extensions/Makefile
2 +++ b/extensions/Makefile
3 @@ -11,13 +11,13 @@ EXT_LIBSI+=$(foreach T,$(EXT_FUNC), -leb
4 EXT_LIBSI+=$(foreach T,$(EXT_TABLES), -lebtable_$(T))
5
6 extensions/ebt_%.so: extensions/ebt_%.o
7 - $(CC) $(LDFLAGS) -shared -o $@ -lc $< -nostartfiles
8 + $(CC) $(LDFLAGS) -shared -o $@ -lc $<
9
10 extensions/libebt_%.so: extensions/ebt_%.so
11 mv $< $@
12
13 extensions/ebtable_%.so: extensions/ebtable_%.o
14 - $(CC) $(LDFLAGS) -shared -o $@ -lc $< -nostartfiles
15 + $(CC) $(LDFLAGS) -shared -o $@ -lc $<
16
17 extensions/libebtable_%.so: extensions/ebtable_%.so
18 mv $< $@
19 --- a/extensions/ebt_802_3.c
20 +++ b/extensions/ebt_802_3.c
21 @@ -141,7 +141,7 @@ static struct ebt_u_match _802_3_match =
22 .extra_ops = opts,
23 };
24
25 -void _init(void)
26 +__attribute__((constructor)) static void extension_init(void)
27 {
28 ebt_register_match(&_802_3_match);
29 }
30 --- a/extensions/ebt_among.c
31 +++ b/extensions/ebt_among.c
32 @@ -490,7 +490,7 @@ static struct ebt_u_match among_match =
33 .extra_ops = opts,
34 };
35
36 -void _init(void)
37 +__attribute__((constructor)) static void extension_init(void)
38 {
39 ebt_register_match(&among_match);
40 }
41 --- a/extensions/ebt_arp.c
42 +++ b/extensions/ebt_arp.c
43 @@ -362,7 +362,7 @@ static struct ebt_u_match arp_match =
44 .extra_ops = opts,
45 };
46
47 -void _init(void)
48 +__attribute__((constructor)) static void extension_init(void)
49 {
50 ebt_register_match(&arp_match);
51 }
52 --- a/extensions/ebt_arpreply.c
53 +++ b/extensions/ebt_arpreply.c
54 @@ -132,7 +132,7 @@ static struct ebt_u_target arpreply_targ
55 .extra_ops = opts,
56 };
57
58 -void _init(void)
59 +__attribute__((constructor)) static void extension_init(void)
60 {
61 ebt_register_target(&arpreply_target);
62 }
63 --- a/extensions/ebt_ip.c
64 +++ b/extensions/ebt_ip.c
65 @@ -338,7 +338,7 @@ static struct ebt_u_match ip_match =
66 .extra_ops = opts,
67 };
68
69 -void _init(void)
70 +__attribute__((constructor)) static void extension_init(void)
71 {
72 ebt_register_match(&ip_match);
73 }
74 --- a/extensions/ebt_ip6.c
75 +++ b/extensions/ebt_ip6.c
76 @@ -556,7 +556,7 @@ static struct ebt_u_match ip6_match =
77 .extra_ops = opts,
78 };
79
80 -void _init(void)
81 +__attribute__((constructor)) static void extension_init(void)
82 {
83 ebt_register_match(&ip6_match);
84 }
85 --- a/extensions/ebt_limit.c
86 +++ b/extensions/ebt_limit.c
87 @@ -212,7 +212,7 @@ static struct ebt_u_match limit_match =
88 .extra_ops = opts,
89 };
90
91 -void _init(void)
92 +__attribute__((constructor)) static void extension_init(void)
93 {
94 ebt_register_match(&limit_match);
95 }
96 --- a/extensions/ebt_log.c
97 +++ b/extensions/ebt_log.c
98 @@ -217,7 +217,7 @@ static struct ebt_u_watcher log_watcher
99 .extra_ops = opts,
100 };
101
102 -void _init(void)
103 +__attribute__((constructor)) static void extension_init(void)
104 {
105 ebt_register_watcher(&log_watcher);
106 }
107 --- a/extensions/ebt_mark.c
108 +++ b/extensions/ebt_mark.c
109 @@ -172,7 +172,7 @@ static struct ebt_u_target mark_target =
110 .extra_ops = opts,
111 };
112
113 -void _init(void)
114 +__attribute__((constructor)) static void extension_init(void)
115 {
116 ebt_register_target(&mark_target);
117 }
118 --- a/extensions/ebt_mark_m.c
119 +++ b/extensions/ebt_mark_m.c
120 @@ -121,7 +121,7 @@ static struct ebt_u_match mark_match =
121 .extra_ops = opts,
122 };
123
124 -void _init(void)
125 +__attribute__((constructor)) static void extension_init(void)
126 {
127 ebt_register_match(&mark_match);
128 }
129 --- a/extensions/ebt_nat.c
130 +++ b/extensions/ebt_nat.c
131 @@ -230,7 +230,7 @@ static struct ebt_u_target dnat_target =
132 .extra_ops = opts_d,
133 };
134
135 -void _init(void)
136 +__attribute__((constructor)) static void extension_init(void)
137 {
138 ebt_register_target(&snat_target);
139 ebt_register_target(&dnat_target);
140 --- a/extensions/ebt_nflog.c
141 +++ b/extensions/ebt_nflog.c
142 @@ -166,7 +166,7 @@ static struct ebt_u_watcher nflog_watche
143 .extra_ops = nflog_opts,
144 };
145
146 -void _init(void)
147 +__attribute__((constructor)) static void extension_init(void)
148 {
149 ebt_register_watcher(&nflog_watcher);
150 }
151 --- a/extensions/ebt_pkttype.c
152 +++ b/extensions/ebt_pkttype.c
153 @@ -125,7 +125,7 @@ static struct ebt_u_match pkttype_match
154 .extra_ops = opts,
155 };
156
157 -void _init(void)
158 +__attribute__((constructor)) static void extension_init(void)
159 {
160 ebt_register_match(&pkttype_match);
161 }
162 --- a/extensions/ebt_redirect.c
163 +++ b/extensions/ebt_redirect.c
164 @@ -108,7 +108,7 @@ static struct ebt_u_target redirect_targ
165 .extra_ops = opts,
166 };
167
168 -void _init(void)
169 +__attribute__((constructor)) static void extension_init(void)
170 {
171 ebt_register_target(&redirect_target);
172 }
173 --- a/extensions/ebt_standard.c
174 +++ b/extensions/ebt_standard.c
175 @@ -84,7 +84,7 @@ static struct ebt_u_target standard =
176 .extra_ops = opts,
177 };
178
179 -void _init(void)
180 +__attribute__((constructor)) static void extension_init(void)
181 {
182 ebt_register_target(&standard);
183 }
184 --- a/extensions/ebt_stp.c
185 +++ b/extensions/ebt_stp.c
186 @@ -337,7 +337,7 @@ static struct ebt_u_match stp_match =
187 .extra_ops = opts,
188 };
189
190 -void _init(void)
191 +__attribute__((constructor)) static void extension_init(void)
192 {
193 ebt_register_match(&stp_match);
194 }
195 --- a/extensions/ebt_ulog.c
196 +++ b/extensions/ebt_ulog.c
197 @@ -180,7 +180,7 @@ static struct ebt_u_watcher ulog_watcher
198 .extra_ops = opts,
199 };
200
201 -void _init(void)
202 +__attribute__((constructor)) static void extension_init(void)
203 {
204 ebt_register_watcher(&ulog_watcher);
205 }
206 --- a/extensions/ebt_vlan.c
207 +++ b/extensions/ebt_vlan.c
208 @@ -181,7 +181,7 @@ static struct ebt_u_match vlan_match = {
209 .extra_ops = opts,
210 };
211
212 -void _init(void)
213 +__attribute__((constructor)) static void extension_init(void)
214 {
215 ebt_register_match(&vlan_match);
216 }
217 --- a/extensions/ebtable_broute.c
218 +++ b/extensions/ebtable_broute.c
219 @@ -23,7 +23,7 @@ ebt_u_table table =
220 .help = print_help,
221 };
222
223 -void _init(void)
224 +__attribute__((constructor)) static void extension_init(void)
225 {
226 ebt_register_table(&table);
227 }
228 --- a/extensions/ebtable_filter.c
229 +++ b/extensions/ebtable_filter.c
230 @@ -29,7 +29,7 @@ static struct ebt_u_table table =
231 .help = print_help,
232 };
233
234 -void _init(void)
235 +__attribute__((constructor)) static void extension_init(void)
236 {
237 ebt_register_table(&table);
238 }
239 --- a/extensions/ebtable_nat.c
240 +++ b/extensions/ebtable_nat.c
241 @@ -30,7 +30,7 @@ ebt_u_table table =
242 .help = print_help,
243 };
244
245 -void _init(void)
246 +__attribute__((constructor)) static void extension_init(void)
247 {
248 ebt_register_table(&table);
249 }