]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/patches/libsafe-alpha.diff
Updated strongswan (4.4.1).
[people/pmueller/ipfire-2.x.git] / src / patches / libsafe-alpha.diff
1 --- libsafe-2.0-16-orig/src/intercept.c 2003-03-15 16:02:12.000000000 +0100
2 +++ libsafe-2.0-16/src/intercept.c 2003-03-15 16:12:22.000000000 +0100
3 @@ -165,7 +165,8 @@
4 */
5 char *strcpy(char *dest, const char *src)
6 {
7 - size_t max_size, len;
8 + uint max_size;
9 + size_t len;
10
11 if (!real_memcpy)
12 real_memcpy = (memcpy_t) getLibraryFunction("memcpy");
13 @@ -196,7 +197,8 @@
14
15 char *strncpy(char *dest, const char *src, size_t n)
16 {
17 - size_t max_size, len;
18 + uint max_size;
19 + size_t len;
20
21 if (!real_strncpy)
22 real_strncpy = (strncpy_t) getLibraryFunction("strncpy");
23 @@ -219,7 +221,8 @@
24
25 char *stpcpy(char *dest, const char *src)
26 {
27 - size_t max_size, len;
28 + uint max_size;
29 + size_t len;
30
31 if (!real_memcpy)
32 real_memcpy = (memcpy_t) getLibraryFunction("memcpy");
33 @@ -251,7 +254,8 @@
34 #ifndef MISSING_WCSNLEN
35 wchar_t *wcscpy(wchar_t *dest, const wchar_t *src)
36 {
37 - size_t max_bytes, max_wchars, len;
38 + size_t max_wchars, len;
39 + uint max_bytes;
40
41 if (!real_wcscpy)
42 real_wcscpy = (wcscpy_t) getLibraryFunction("wcscpy");
43 @@ -291,7 +295,8 @@
44
45 wchar_t *wcpcpy(wchar_t *dest, const wchar_t *src)
46 {
47 - size_t max_bytes, max_wchars, len;
48 + size_t max_wchars, len;
49 + uint max_bytes;
50
51 if (!real_wcpcpy)
52 real_wcpcpy = (wcpcpy_t) getLibraryFunction("wcpcpy");
53 @@ -333,9 +338,15 @@
54 /*
55 * This is needed! See the strcpy() for the reason. -ab.
56 */
57 -void *memcpy(void *dest, const void *src, size_t n)
58 +void *memcpy(void *dest, const void *src, size_t hack)
59 {
60 - size_t max_size;
61 + /*
62 + * a size_t IS an unsigned long everywhere, though it sometimes
63 + * doesn't state so, making printf misinterpret it.
64 + */
65 + unsigned long n = hack;
66 + uint max_size;
67 +
68
69 if (!real_memcpy)
70 real_memcpy = (memcpy_t) getLibraryFunction("memcpy");
71 @@ -344,11 +355,11 @@
72 return real_memcpy(dest, src, n);
73
74 if ((max_size = _libsafe_stackVariableP(dest)) == 0) {
75 - LOG(5, "memcpy(<heap var> , <src>, %d)\n", n);
76 + LOG(5, "memcpy(<heap var> , <src>, %ld)\n", n);
77 return real_memcpy(dest, src, n);
78 }
79
80 - LOG(4, "memcpy(<stack var> , <src>, %d) stack limit=%d)\n", n, max_size);
81 + LOG(4, "memcpy(<stack var> , <src>, %ld) stack limit=%d)\n", n, max_size);
82 if (n > max_size)
83 _libsafe_die("Overflow caused by memcpy()");
84 return real_memcpy(dest, src, n);
85 @@ -357,7 +368,7 @@
86
87 char *strcat(char *dest, const char *src)
88 {
89 - size_t max_size;
90 + uint max_size;
91 uint dest_len, src_len;
92
93 if (!real_memcpy)
94 @@ -388,7 +399,7 @@
95
96 char *strncat(char *dest, const char *src, size_t n)
97 {
98 - size_t max_size;
99 + uint max_size;
100 uint dest_len, src_len;
101
102 if (!real_strncat)
103 @@ -1008,12 +1019,31 @@
104 if (is_printf_convspec[(int)*p]) {
105 caddr_t addr;
106 c++;
107 +#if 0
108 + /*
109 + * cannot add va_list (ap here) with a number on alpha.
110 + * this is faster than the other method, and might be
111 + * a good idea to enable this on !alpha arch.
112 + */
113 if (pnum) {
114 addr = *((caddr_t*)(ap + (atoi(pnum)-1)*sizeof(char*)));
115 }
116 else {
117 addr = *((caddr_t*)(ap + c*sizeof(char*)));
118 }
119 +#else
120 + {
121 + va_list apc;
122 + uint nb = c + 1;
123 +
124 + va_copy(apc, ap);
125 + if (pnum)
126 + nb = atoi(pnum);
127 + addr = NULL;
128 + while (nb--)
129 + addr = va_arg(apc, caddr_t);
130 + }
131 +#endif
132 if (*p == 'n') {
133 if (_libsafe_raVariableP((void *)(addr))) {
134 _libsafe_die("printf(\"%%n\")");
135 @@ -1172,12 +1202,32 @@
136 if (is_printf_convspec[(int)*p]) {
137 caddr_t addr;
138 c++;
139 +#if 0
140 + /*
141 + * cannot add va_list (ap here) with a number on alpha.
142 + * this is faster than the other method, and might be
143 + * a good idea to enable this on !alpha arch.
144 + */
145 +
146 if (pnum) {
147 addr = *((caddr_t*)(ap + (atoi(pnum)-1)*sizeof(char*)));
148 }
149 else {
150 addr = *((caddr_t*)(ap + c*sizeof(char*)));
151 }
152 +#else
153 + {
154 + va_list apc;
155 + uint nb = c + 1;
156 +
157 + va_copy(apc, ap);
158 + if (pnum)
159 + nb = atoi(pnum);
160 + addr = NULL;
161 + while (nb--)
162 + addr = va_arg(apc, caddr_t);
163 + }
164 +#endif
165 if (*p == 'n') {
166 if (_libsafe_raVariableP((void *)(addr))) {
167 _libsafe_die("printf(\"%%n\")");
168 @@ -1194,7 +1244,7 @@
169
170 int sprintf(char *str, const char *format, ...)
171 {
172 - size_t max_size;
173 + uint max_size;
174 va_list ap;
175 int res;
176
177 @@ -1242,7 +1292,7 @@
178
179 int snprintf(char *str, size_t size, const char *format, ...)
180 {
181 - size_t max_size;
182 + uint max_size;
183 va_list ap;
184 int res;
185
186 @@ -1288,7 +1338,7 @@
187
188 int vsprintf(char *str, const char *format, va_list ap)
189 {
190 - size_t max_size;
191 + uint max_size;
192 int res;
193
194 if (!real_vsprintf)
195 @@ -1325,7 +1375,7 @@
196
197 int vsnprintf(char *str, size_t size, const char *format, va_list ap)
198 {
199 - size_t max_size;
200 + uint max_size;
201 int res;
202
203 if (!real_vsnprintf)
204 @@ -1360,7 +1410,7 @@
205
206 char *getwd(char *buf)
207 {
208 - size_t max_size;
209 + uint max_size;
210 char *res;
211
212 if (!real_getwd)
213 @@ -1384,7 +1434,8 @@
214
215 char *gets(char *s)
216 {
217 - size_t max_size, len;
218 + uint max_size;
219 + size_t len;
220
221 if (!real_gets)
222 real_gets = (gets_t) getLibraryFunction("gets");
223 @@ -1409,7 +1460,8 @@
224
225 char *realpath(char *path, char resolved_path[])
226 {
227 - size_t max_size, len;
228 + uint max_size;
229 + size_t len;
230 char *res;
231 char buf[MAXPATHLEN + 1];
232