summaryrefslogtreecommitdiff
path: root/packages/openswan/openswan-2.2.0/gcc4-fixes.patch
blob: 0e5f6ebe47c2a7bd8ff78230d2536f69762a2ae3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
Index: openswan-2.2.0/linux/lib/libfreeswan/pfkey_v2_build.c
===================================================================
--- openswan-2.2.0.orig/linux/lib/libfreeswan/pfkey_v2_build.c	2004-04-12 02:59:06.000000000 +0000
+++ openswan-2.2.0/linux/lib/libfreeswan/pfkey_v2_build.c	2005-11-14 13:49:01.000000000 +0000
@@ -173,9 +173,9 @@
 		SENDERR(EINVAL);
 	}
 
-	if(!(*pfkey_ext = (struct sadb_ext*)
-	     pfkey_msg = (struct sadb_msg*)
-	     MALLOC(sizeof(struct sadb_msg)))) {
+	pfkey_msg = (struct sadb_msg*)MALLOC(sizeof(struct sadb_msg));
+	*pfkey_ext = (struct sadb_ext*)pfkey_msg;
+	if(NULL == pfkey_msg) {
 		DEBUGGING(PF_KEY_DEBUG_BUILD,
 			"pfkey_msg_hdr_build: "
 			"memory allocation failed\n");
@@ -297,9 +297,9 @@
 		SENDERR(EINVAL);
 	}
 	
-	if(!(*pfkey_ext = (struct sadb_ext*)
-	     pfkey_sa = (struct sadb_sa*)
-	     MALLOC(sizeof(struct sadb_sa)))) {
+	pfkey_sa = (struct sadb_sa*)MALLOC(sizeof(struct sadb_sa));
+	*pfkey_ext = (struct sadb_ext*)pfkey_sa;
+	if (NULL == pfkey_sa) {
 		DEBUGGING(PF_KEY_DEBUG_BUILD,
 			"pfkey_sa_build: "
 			"memory allocation failed\n");
@@ -374,9 +374,9 @@
 		SENDERR(EINVAL);
 	}
 
-	if(!(*pfkey_ext = (struct sadb_ext*)
-	     pfkey_lifetime = (struct sadb_lifetime*)
-	     MALLOC(sizeof(struct sadb_lifetime)))) {
+	pfkey_lifetime = (struct sadb_lifetime*)MALLOC(sizeof(struct sadb_lifetime));
+	*pfkey_ext = (struct sadb_ext*)pfkey_lifetime;
+	if (NULL == pfkey_lifetime) {
 		DEBUGGING(PF_KEY_DEBUG_BUILD,
 			"pfkey_lifetime_build: "
 			"memory allocation failed\n");
@@ -563,10 +563,11 @@
 		SENDERR(EINVAL);
 	}
 
-	if(!(*pfkey_ext = (struct sadb_ext*)
-	     pfkey_key = (struct sadb_key*)
-	     MALLOC(sizeof(struct sadb_key) +
-				    DIVUP(key_bits, 64) * IPSEC_PFKEYv2_ALIGN))) {
+	pfkey_key = (struct sadb_key*)
+		MALLOC(sizeof(struct sadb_key) +
+			DIVUP(key_bits, 64) * IPSEC_PFKEYv2_ALIGN);
+	*pfkey_ext = (struct sadb_ext*)pfkey_key;
+	if (NULL == pfkey_key) {
 		ERROR("pfkey_key_build: "
 			"memory allocation failed\n");
 		SENDERR(ENOMEM);
@@ -643,10 +644,11 @@
 	if((ident_type == SADB_IDENTTYPE_USERFQDN) ) {
 	}
 #endif
-	    
-	if(!(*pfkey_ext = (struct sadb_ext*)
-	     pfkey_ident = (struct sadb_ident*)
-	     MALLOC(ident_len * IPSEC_PFKEYv2_ALIGN))) {
+
+	pfkey_ident = (struct sadb_ident*)
+		MALLOC(ident_len * IPSEC_PFKEYv2_ALIGN);
+	*pfkey_ext = (struct sadb_ext*)pfkey_ident;
+	if (NULL == pfkey_ident) {
 		ERROR("pfkey_ident_build: "
 			"memory allocation failed\n");
 		SENDERR(ENOMEM);
@@ -696,10 +698,11 @@
 		(*pfkey_ext)->sadb_ext_type);
 	SENDERR(EINVAL); /* don't process these yet */
 
-	if(!(*pfkey_ext = (struct sadb_ext*)
-	     pfkey_sens = (struct sadb_sens*)
-	     MALLOC(sizeof(struct sadb_sens) +
-		    (sens_len + integ_len) * sizeof(uint64_t)))) {
+	pfkey_sens = (struct sadb_sens*)
+		MALLOC(sizeof(struct sadb_sens) +
+		    (sens_len + integ_len) * sizeof(uint64_t));
+	*pfkey_ext = (struct sadb_ext*)pfkey_sens;
+	if (NULL == pfkey_sens) {
 		ERROR("pfkey_sens_build: "
 			"memory allocation failed\n");
 		SENDERR(ENOMEM);
@@ -753,10 +756,11 @@
 		SENDERR(EINVAL);
 	}
 
-	if(!(*pfkey_ext = (struct sadb_ext*)
-	     pfkey_prop = (struct sadb_prop*)
-	     MALLOC(sizeof(struct sadb_prop) +
-		    comb_num * sizeof(struct sadb_comb)))) {
+	pfkey_prop = (struct sadb_prop*)
+		MALLOC(sizeof(struct sadb_prop) +
+			comb_num * sizeof(struct sadb_comb));		
+	*pfkey_ext = (struct sadb_ext*)pfkey_prop;
+	if (NULL == pfkey_prop) {
 		ERROR("pfkey_prop_build: "
 			"memory allocation failed\n");
 		SENDERR(ENOMEM);
@@ -833,11 +837,11 @@
 		SENDERR(EINVAL);
 	}
 
-	if(!(*pfkey_ext = (struct sadb_ext*)
-	     pfkey_supported = (struct sadb_supported*)
-	     MALLOC(sizeof(struct sadb_supported) +
-					       alg_num *
-					       sizeof(struct sadb_alg)))) {
+	pfkey_supported = (struct sadb_supported*)
+		MALLOC(sizeof(struct sadb_supported) +
+			alg_num * sizeof(struct sadb_alg));
+	*pfkey_ext = (struct sadb_ext*)pfkey_supported;
+	if (NULL == pfkey_supported) {
 		DEBUGGING(PF_KEY_DEBUG_BUILD,
 			"pfkey_supported_build: "
 			"memory allocation failed\n");
@@ -913,10 +917,11 @@
 			ntohl(min));
 		SENDERR(EEXIST);
 	}
-	
-	if(!(*pfkey_ext = (struct sadb_ext*)
-	     pfkey_spirange = (struct sadb_spirange*)
-	     MALLOC(sizeof(struct sadb_spirange)))) {
+
+	pfkey_spirange = (struct sadb_spirange*)
+		MALLOC(sizeof(struct sadb_spirange));
+	*pfkey_ext = (struct sadb_ext*)pfkey_spirange;
+	if (NULL == pfkey_spirange) {
 		DEBUGGING(PF_KEY_DEBUG_BUILD,
 			"pfkey_spirange_build: "
 			"memory allocation failed\n");
@@ -958,9 +963,10 @@
 		(*pfkey_ext)->sadb_ext_type);
 	SENDERR(EINVAL); /* don't process these yet */
 
-	if(!(*pfkey_ext = (struct sadb_ext*)
-	     pfkey_x_kmprivate = (struct sadb_x_kmprivate*)
-	     MALLOC(sizeof(struct sadb_x_kmprivate)))) {
+	pfkey_x_kmprivate = (struct sadb_x_kmprivate*)
+		MALLOC(sizeof(struct sadb_x_kmprivate));
+	*pfkey_ext = (struct sadb_ext*)pfkey_x_kmprivate;
+	if (NULL == pfkey_x_kmprivate) {
 		DEBUGGING(PF_KEY_DEBUG_BUILD,
 			"pfkey_x_kmprivate_build: "
 			"memory allocation failed\n");
@@ -1009,8 +1015,10 @@
 		SENDERR(EINVAL);
 	}
 
-	if(!(*pfkey_ext = (struct sadb_ext*)pfkey_x_satype = (struct sadb_x_satype*)
-	     MALLOC(sizeof(struct sadb_x_satype)))) {
+	pfkey_x_satype = (struct sadb_x_satype*)
+		MALLOC(sizeof(struct sadb_x_satype));
+	*pfkey_ext = (struct sadb_ext*)pfkey_x_satype;
+	if (NULL == pfkey_x_satype) {
 		ERROR("pfkey_x_satype_build: "
 			"memory allocation failed\n");
 		SENDERR(ENOMEM);
@@ -1064,8 +1072,10 @@
 		"tunnel=%x netlink=%x xform=%x eroute=%x spi=%x radij=%x esp=%x ah=%x rcv=%x pfkey=%x ipcomp=%x verbose=%x?\n",
 		tunnel, netlink, xform, eroute, spi, radij, esp, ah, rcv, pfkey, ipcomp, verbose);
 
-	if(!(*pfkey_ext = (struct sadb_ext*)pfkey_x_debug = (struct sadb_x_debug*)
-	     MALLOC(sizeof(struct sadb_x_debug)))) {
+	pfkey_x_debug = (struct sadb_x_debug*)
+		MALLOC(sizeof(struct sadb_x_debug));
+	*pfkey_ext = (struct sadb_ext*)pfkey_x_debug;
+	if (NULL == pfkey_x_debug) {
 		ERROR("pfkey_x_debug_build: "
 			"memory allocation failed\n");
 		SENDERR(ENOMEM);
@@ -1122,8 +1132,10 @@
 		"pfkey_x_nat_t_type_build: "
 		"type=%d\n", type);
 
-	if(!(*pfkey_ext = (struct sadb_ext*)pfkey_x_nat_t_type = (struct sadb_x_nat_t_type*)
-	     MALLOC(sizeof(struct sadb_x_nat_t_type)))) {
+	pfkey_x_nat_t_type = (struct sadb_x_nat_t_type*)
+		MALLOC(sizeof(struct sadb_x_nat_t_type));
+	*pfkey_ext = (struct sadb_ext*)pfkey_x_nat_t_type;
+	if (NULL == pfkey_x_nat_t_type) {
 		DEBUGGING(PF_KEY_DEBUG_BUILD,
 			"pfkey_x_nat_t_type_build: "
 			"memory allocation failed\n");
@@ -1174,8 +1186,10 @@
 		"pfkey_x_nat_t_port_build: "
 		"ext=%d, port=%d\n", exttype, port);
 
-	if(!(*pfkey_ext = (struct sadb_ext*)pfkey_x_nat_t_port = (struct sadb_x_nat_t_port*)
-	     MALLOC(sizeof(struct sadb_x_nat_t_port)))) {
+	pfkey_x_nat_t_port = (struct sadb_x_nat_t_port*)
+		MALLOC(sizeof(struct sadb_x_nat_t_port));
+	*pfkey_ext = (struct sadb_ext*)pfkey_x_nat_t_port;
+	if (NULL == pfkey_x_nat_t_port) {
 		DEBUGGING(PF_KEY_DEBUG_BUILD,
 			"pfkey_x_nat_t_port_build: "
 			"memory allocation failed\n");
@@ -1328,7 +1342,12 @@
 			memcpy(pfkey_ext,
 			       extensions[ext],
 			       (extensions[ext])->sadb_ext_len * IPSEC_PFKEYv2_ALIGN);
-			((char*)pfkey_ext) += (extensions[ext])->sadb_ext_len * IPSEC_PFKEYv2_ALIGN;
+			{
+				char *pfkey_ext_c = (char *)pfkey_ext;
+				
+				pfkey_ext_c += (extensions[ext])->sadb_ext_len * IPSEC_PFKEYv2_ALIGN;
+				pfkey_ext = (struct sadb_ext *)pfkey_ext_c;
+			}
 			/* Mark that we have seen this extension and remember the header location */
 			extensions_seen |= ( 1 << ext );
 		}
Index: openswan-2.2.0/programs/pluto/connections.c
===================================================================
--- openswan-2.2.0.orig/programs/pluto/connections.c	2004-06-27 20:46:15.000000000 +0000
+++ openswan-2.2.0/programs/pluto/connections.c	2005-11-14 14:01:09.000000000 +0000
@@ -30,6 +30,7 @@
 
 #include <openswan.h>
 #include <openswan/ipsec_policy.h>
+#include "pfkeyv2.h"
 #include "kameipsec.h"
 
 #include "constants.h"
Index: openswan-2.2.0/programs/pluto/ipsec_doi.c
===================================================================
--- openswan-2.2.0.orig/programs/pluto/ipsec_doi.c	2004-09-02 01:24:23.000000000 +0000
+++ openswan-2.2.0/programs/pluto/ipsec_doi.c	2005-11-14 14:03:17.000000000 +0000
@@ -31,6 +31,7 @@
 
 #include <openswan.h>
 #include <openswan/ipsec_policy.h>
+#include "pfkeyv2.h"
 
 #include "constants.h"
 #include "defs.h"
Index: openswan-2.2.0/programs/pluto/rcv_whack.c
===================================================================
--- openswan-2.2.0.orig/programs/pluto/rcv_whack.c	2004-06-14 02:01:32.000000000 +0000
+++ openswan-2.2.0/programs/pluto/rcv_whack.c	2005-11-14 14:04:08.000000000 +0000
@@ -31,6 +31,7 @@
 #include <sys/queue.h>
 
 #include <openswan.h>
+#include "pfkeyv2.h"
 
 #include "constants.h"
 #include "defs.h"
Index: openswan-2.2.0/programs/pluto/log.c
===================================================================
--- openswan-2.2.0.orig/programs/pluto/log.c	2004-06-14 01:46:03.000000000 +0000
+++ openswan-2.2.0/programs/pluto/log.c	2005-11-14 14:02:33.000000000 +0000
@@ -30,6 +30,7 @@
 #include <sys/types.h>
 
 #include <openswan.h>
+#include "pfkeyv2.h"
 
 #include "constants.h"
 #include "oswlog.h"
Index: openswan-2.2.0/programs/pluto/spdb.c
===================================================================
--- openswan-2.2.0.orig/programs/pluto/spdb.c	2004-05-25 22:25:02.000000000 +0000
+++ openswan-2.2.0/programs/pluto/spdb.c	2005-11-14 14:02:55.000000000 +0000
@@ -24,6 +24,7 @@
 
 #include <openswan.h>
 #include <openswan/ipsec_policy.h>
+#include "pfkeyv2.h"
 
 #include "constants.h"
 #include "oswlog.h"
Index: openswan-2.2.0/programs/pluto/db_ops.c
===================================================================
--- openswan-2.2.0.orig/programs/pluto/db_ops.c	2004-06-04 01:59:33.000000000 +0000
+++ openswan-2.2.0/programs/pluto/db_ops.c	2005-11-14 13:54:10.000000000 +0000
@@ -181,7 +181,13 @@
 	ctx->trans0 = ctx->prop.trans = new_trans;
 	/* update trans_cur (by offset) */
 	offset = (char *)(new_trans) - (char *)(old_trans);
-	(char *)(ctx->trans_cur) += offset;
+
+	{
+	  char *cctx = (char *)(ctx->trans_cur);
+	  
+	  cctx += offset;
+	  ctx->trans_cur = (struct db_trans *)cctx;
+	}
 	/* update elem count */
 	ctx->max_trans = max_trans;
 	PFREE_ST(old_trans, db_trans_st);
@@ -213,12 +219,25 @@
 	
 	/* update attrs0 and attrs_cur (obviously) */
 	offset = (char *)(new_attrs) - (char *)(old_attrs);
-	(char *)ctx->attrs0 += offset;
-	(char *)ctx->attrs_cur += offset;
+	{
+	  char *actx = (char *)(ctx->attrs0);
+	  
+	  actx += offset;
+	  ctx->attrs0 = (struct db_attr *)actx;
+	  
+	  actx = (char *)ctx->attrs_cur;
+	  actx += offset;
+	  ctx->attrs_cur = (struct db_attr *)actx;
+	}
+
 	/* for each transform, rewrite attrs pointer by offsetting it */
-	for (t=ctx->prop.trans, ti=0; ti < ctx->prop.trans_cnt; t++, ti++) {
-		(char *)(t->attrs) += offset;
+        for (t=ctx->prop.trans, ti=0; ti < ctx->prop.trans_cnt; t++, ti++) {
+			char *actx = (char *)(t->attrs);
+	 
+			actx += offset;
+			t->attrs = (struct db_attr *)actx;
 	}
+
 	/* update elem count */
 	ctx->max_attrs = max_attrs;
 	PFREE_ST(old_attrs, db_attrs_st);