sl@0
|
1 |
/* dso_dlfcn.c -*- mode:C; c-file-style: "eay" -*- */
|
sl@0
|
2 |
/* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL
|
sl@0
|
3 |
* project 2000.
|
sl@0
|
4 |
*/
|
sl@0
|
5 |
/* ====================================================================
|
sl@0
|
6 |
* Copyright (c) 2000 The OpenSSL Project. All rights reserved.
|
sl@0
|
7 |
*
|
sl@0
|
8 |
* Redistribution and use in source and binary forms, with or without
|
sl@0
|
9 |
* modification, are permitted provided that the following conditions
|
sl@0
|
10 |
* are met:
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* 1. Redistributions of source code must retain the above copyright
|
sl@0
|
13 |
* notice, this list of conditions and the following disclaimer.
|
sl@0
|
14 |
*
|
sl@0
|
15 |
* 2. Redistributions in binary form must reproduce the above copyright
|
sl@0
|
16 |
* notice, this list of conditions and the following disclaimer in
|
sl@0
|
17 |
* the documentation and/or other materials provided with the
|
sl@0
|
18 |
* distribution.
|
sl@0
|
19 |
*
|
sl@0
|
20 |
* 3. All advertising materials mentioning features or use of this
|
sl@0
|
21 |
* software must display the following acknowledgment:
|
sl@0
|
22 |
* "This product includes software developed by the OpenSSL Project
|
sl@0
|
23 |
* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
|
sl@0
|
24 |
*
|
sl@0
|
25 |
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
sl@0
|
26 |
* endorse or promote products derived from this software without
|
sl@0
|
27 |
* prior written permission. For written permission, please contact
|
sl@0
|
28 |
* licensing@OpenSSL.org.
|
sl@0
|
29 |
*
|
sl@0
|
30 |
* 5. Products derived from this software may not be called "OpenSSL"
|
sl@0
|
31 |
* nor may "OpenSSL" appear in their names without prior written
|
sl@0
|
32 |
* permission of the OpenSSL Project.
|
sl@0
|
33 |
*
|
sl@0
|
34 |
* 6. Redistributions of any form whatsoever must retain the following
|
sl@0
|
35 |
* acknowledgment:
|
sl@0
|
36 |
* "This product includes software developed by the OpenSSL Project
|
sl@0
|
37 |
* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
|
sl@0
|
38 |
*
|
sl@0
|
39 |
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
sl@0
|
40 |
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
sl@0
|
41 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
sl@0
|
42 |
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
sl@0
|
43 |
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
sl@0
|
44 |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
sl@0
|
45 |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
sl@0
|
46 |
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
sl@0
|
47 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
sl@0
|
48 |
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
sl@0
|
49 |
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
sl@0
|
50 |
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
sl@0
|
51 |
* ====================================================================
|
sl@0
|
52 |
*
|
sl@0
|
53 |
* This product includes cryptographic software written by Eric Young
|
sl@0
|
54 |
* (eay@cryptsoft.com). This product includes software written by Tim
|
sl@0
|
55 |
* Hudson (tjh@cryptsoft.com).
|
sl@0
|
56 |
*
|
sl@0
|
57 |
*/
|
sl@0
|
58 |
/*
|
sl@0
|
59 |
© Portions copyright (c) 2006 Nokia Corporation. All rights reserved.
|
sl@0
|
60 |
*/
|
sl@0
|
61 |
|
sl@0
|
62 |
|
sl@0
|
63 |
#include <stdio.h>
|
sl@0
|
64 |
#include "cryptlib.h"
|
sl@0
|
65 |
#include <openssl/dso.h>
|
sl@0
|
66 |
#if (defined(SYMBIAN) && (defined(__WINSCW__) || defined(__WINS__)))
|
sl@0
|
67 |
#include "libcrypto_wsd_macros.h"
|
sl@0
|
68 |
#include "libcrypto_wsd.h"
|
sl@0
|
69 |
#endif
|
sl@0
|
70 |
|
sl@0
|
71 |
#ifndef DSO_DLFCN
|
sl@0
|
72 |
DSO_METHOD *DSO_METHOD_dlfcn(void)
|
sl@0
|
73 |
{
|
sl@0
|
74 |
return NULL;
|
sl@0
|
75 |
}
|
sl@0
|
76 |
|
sl@0
|
77 |
#else
|
sl@0
|
78 |
|
sl@0
|
79 |
#ifdef HAVE_DLFCN_H
|
sl@0
|
80 |
#include <dlfcn.h>
|
sl@0
|
81 |
#endif
|
sl@0
|
82 |
|
sl@0
|
83 |
/* Part of the hack in "dlfcn_load" ... */
|
sl@0
|
84 |
#define DSO_MAX_TRANSLATED_SIZE 256
|
sl@0
|
85 |
|
sl@0
|
86 |
static int dlfcn_load(DSO *dso);
|
sl@0
|
87 |
static int dlfcn_unload(DSO *dso);
|
sl@0
|
88 |
static void *dlfcn_bind_var(DSO *dso, const char *symname);
|
sl@0
|
89 |
static DSO_FUNC_TYPE dlfcn_bind_func(DSO *dso, const char *symname);
|
sl@0
|
90 |
#if 0
|
sl@0
|
91 |
static int dlfcn_unbind(DSO *dso, char *symname, void *symptr);
|
sl@0
|
92 |
static int dlfcn_init(DSO *dso);
|
sl@0
|
93 |
static int dlfcn_finish(DSO *dso);
|
sl@0
|
94 |
static long dlfcn_ctrl(DSO *dso, int cmd, long larg, void *parg);
|
sl@0
|
95 |
#endif
|
sl@0
|
96 |
static char *dlfcn_name_converter(DSO *dso, const char *filename);
|
sl@0
|
97 |
static char *dlfcn_merger(DSO *dso, const char *filespec1,
|
sl@0
|
98 |
const char *filespec2);
|
sl@0
|
99 |
|
sl@0
|
100 |
#ifndef EMULATOR
|
sl@0
|
101 |
static DSO_METHOD dso_meth_dlfcn = {
|
sl@0
|
102 |
"OpenSSL 'dlfcn' shared library method",
|
sl@0
|
103 |
dlfcn_load,
|
sl@0
|
104 |
dlfcn_unload,
|
sl@0
|
105 |
dlfcn_bind_var,
|
sl@0
|
106 |
dlfcn_bind_func,
|
sl@0
|
107 |
/* For now, "unbind" doesn't exist */
|
sl@0
|
108 |
#if 0
|
sl@0
|
109 |
NULL, /* unbind_var */
|
sl@0
|
110 |
NULL, /* unbind_func */
|
sl@0
|
111 |
#endif
|
sl@0
|
112 |
NULL, /* ctrl */
|
sl@0
|
113 |
dlfcn_name_converter,
|
sl@0
|
114 |
dlfcn_merger,
|
sl@0
|
115 |
NULL, /* init */
|
sl@0
|
116 |
NULL /* finish */
|
sl@0
|
117 |
};
|
sl@0
|
118 |
#else
|
sl@0
|
119 |
GET_STATIC_VAR_FROM_TLS(dso_meth_dlfcn,dso_dlfcn,DSO_METHOD)
|
sl@0
|
120 |
#define dso_meth_dlfcn (*GET_WSD_VAR_NAME(dso_meth_dlfcn,dso_dlfcn, s)())
|
sl@0
|
121 |
const DSO_METHOD temp_s_dso_meth_dlfcn = {
|
sl@0
|
122 |
"OpenSSL 'dlfcn' shared library method",
|
sl@0
|
123 |
dlfcn_load,
|
sl@0
|
124 |
dlfcn_unload,
|
sl@0
|
125 |
dlfcn_bind_var,
|
sl@0
|
126 |
dlfcn_bind_func,
|
sl@0
|
127 |
/* For now, "unbind" doesn't exist */
|
sl@0
|
128 |
#if 0
|
sl@0
|
129 |
NULL, /* unbind_var */
|
sl@0
|
130 |
NULL, /* unbind_func */
|
sl@0
|
131 |
#endif
|
sl@0
|
132 |
NULL, /* ctrl */
|
sl@0
|
133 |
dlfcn_name_converter,
|
sl@0
|
134 |
dlfcn_merger,
|
sl@0
|
135 |
NULL, /* init */
|
sl@0
|
136 |
NULL /* finish */
|
sl@0
|
137 |
};
|
sl@0
|
138 |
|
sl@0
|
139 |
#endif
|
sl@0
|
140 |
EXPORT_C DSO_METHOD *DSO_METHOD_dlfcn(void)
|
sl@0
|
141 |
{
|
sl@0
|
142 |
return(&dso_meth_dlfcn);
|
sl@0
|
143 |
}
|
sl@0
|
144 |
|
sl@0
|
145 |
/* Prior to using the dlopen() function, we should decide on the flag
|
sl@0
|
146 |
* we send. There's a few different ways of doing this and it's a
|
sl@0
|
147 |
* messy venn-diagram to match up which platforms support what. So
|
sl@0
|
148 |
* as we don't have autoconf yet, I'm implementing a hack that could
|
sl@0
|
149 |
* be hacked further relatively easily to deal with cases as we find
|
sl@0
|
150 |
* them. Initially this is to cope with OpenBSD. */
|
sl@0
|
151 |
#if defined(__OpenBSD__) || defined(__NetBSD__)
|
sl@0
|
152 |
# ifdef DL_LAZY
|
sl@0
|
153 |
# define DLOPEN_FLAG DL_LAZY
|
sl@0
|
154 |
# else
|
sl@0
|
155 |
# ifdef RTLD_NOW
|
sl@0
|
156 |
# define DLOPEN_FLAG RTLD_NOW
|
sl@0
|
157 |
# else
|
sl@0
|
158 |
# define DLOPEN_FLAG 0
|
sl@0
|
159 |
# endif
|
sl@0
|
160 |
# endif
|
sl@0
|
161 |
#else
|
sl@0
|
162 |
# ifdef OPENSSL_SYS_SUNOS
|
sl@0
|
163 |
# define DLOPEN_FLAG 1
|
sl@0
|
164 |
# else
|
sl@0
|
165 |
# define DLOPEN_FLAG RTLD_NOW /* Hope this works everywhere else */
|
sl@0
|
166 |
# endif
|
sl@0
|
167 |
#endif
|
sl@0
|
168 |
|
sl@0
|
169 |
/* For this DSO_METHOD, our meth_data STACK will contain;
|
sl@0
|
170 |
* (i) the handle (void*) returned from dlopen().
|
sl@0
|
171 |
*/
|
sl@0
|
172 |
|
sl@0
|
173 |
static int dlfcn_load(DSO *dso)
|
sl@0
|
174 |
{
|
sl@0
|
175 |
void *ptr = NULL;
|
sl@0
|
176 |
/* See applicable comments in dso_dl.c */
|
sl@0
|
177 |
char *filename = DSO_convert_filename(dso, NULL);
|
sl@0
|
178 |
int flags = DLOPEN_FLAG;
|
sl@0
|
179 |
|
sl@0
|
180 |
if(filename == NULL)
|
sl@0
|
181 |
{
|
sl@0
|
182 |
DSOerr(DSO_F_DLFCN_LOAD,DSO_R_NO_FILENAME);
|
sl@0
|
183 |
goto err;
|
sl@0
|
184 |
}
|
sl@0
|
185 |
|
sl@0
|
186 |
#ifdef RTLD_GLOBAL
|
sl@0
|
187 |
if (dso->flags & DSO_FLAG_GLOBAL_SYMBOLS)
|
sl@0
|
188 |
flags |= RTLD_GLOBAL;
|
sl@0
|
189 |
#endif
|
sl@0
|
190 |
ptr = dlopen(filename, flags);
|
sl@0
|
191 |
if(ptr == NULL)
|
sl@0
|
192 |
{
|
sl@0
|
193 |
DSOerr(DSO_F_DLFCN_LOAD,DSO_R_LOAD_FAILED);
|
sl@0
|
194 |
ERR_add_error_data(4, "filename(", filename, "): ", dlerror());
|
sl@0
|
195 |
goto err;
|
sl@0
|
196 |
}
|
sl@0
|
197 |
if(!sk_push(dso->meth_data, (char *)ptr))
|
sl@0
|
198 |
{
|
sl@0
|
199 |
DSOerr(DSO_F_DLFCN_LOAD,DSO_R_STACK_ERROR);
|
sl@0
|
200 |
goto err;
|
sl@0
|
201 |
}
|
sl@0
|
202 |
/* Success */
|
sl@0
|
203 |
dso->loaded_filename = filename;
|
sl@0
|
204 |
return(1);
|
sl@0
|
205 |
err:
|
sl@0
|
206 |
/* Cleanup! */
|
sl@0
|
207 |
if(filename != NULL)
|
sl@0
|
208 |
OPENSSL_free(filename);
|
sl@0
|
209 |
if(ptr != NULL)
|
sl@0
|
210 |
dlclose(ptr);
|
sl@0
|
211 |
return(0);
|
sl@0
|
212 |
}
|
sl@0
|
213 |
|
sl@0
|
214 |
static int dlfcn_unload(DSO *dso)
|
sl@0
|
215 |
{
|
sl@0
|
216 |
void *ptr;
|
sl@0
|
217 |
if(dso == NULL)
|
sl@0
|
218 |
{
|
sl@0
|
219 |
DSOerr(DSO_F_DLFCN_UNLOAD,ERR_R_PASSED_NULL_PARAMETER);
|
sl@0
|
220 |
return(0);
|
sl@0
|
221 |
}
|
sl@0
|
222 |
if(sk_num(dso->meth_data) < 1)
|
sl@0
|
223 |
return(1);
|
sl@0
|
224 |
ptr = (void *)sk_pop(dso->meth_data);
|
sl@0
|
225 |
if(ptr == NULL)
|
sl@0
|
226 |
{
|
sl@0
|
227 |
DSOerr(DSO_F_DLFCN_UNLOAD,DSO_R_NULL_HANDLE);
|
sl@0
|
228 |
/* Should push the value back onto the stack in
|
sl@0
|
229 |
* case of a retry. */
|
sl@0
|
230 |
sk_push(dso->meth_data, (char *)ptr);
|
sl@0
|
231 |
return(0);
|
sl@0
|
232 |
}
|
sl@0
|
233 |
/* For now I'm not aware of any errors associated with dlclose() */
|
sl@0
|
234 |
dlclose(ptr);
|
sl@0
|
235 |
return(1);
|
sl@0
|
236 |
}
|
sl@0
|
237 |
|
sl@0
|
238 |
static void *dlfcn_bind_var(DSO *dso, const char *symname)
|
sl@0
|
239 |
{
|
sl@0
|
240 |
void *ptr, *sym;
|
sl@0
|
241 |
|
sl@0
|
242 |
if((dso == NULL) || (symname == NULL))
|
sl@0
|
243 |
{
|
sl@0
|
244 |
DSOerr(DSO_F_DLFCN_BIND_VAR,ERR_R_PASSED_NULL_PARAMETER);
|
sl@0
|
245 |
return(NULL);
|
sl@0
|
246 |
}
|
sl@0
|
247 |
if(sk_num(dso->meth_data) < 1)
|
sl@0
|
248 |
{
|
sl@0
|
249 |
DSOerr(DSO_F_DLFCN_BIND_VAR,DSO_R_STACK_ERROR);
|
sl@0
|
250 |
return(NULL);
|
sl@0
|
251 |
}
|
sl@0
|
252 |
ptr = (void *)sk_value(dso->meth_data, sk_num(dso->meth_data) - 1);
|
sl@0
|
253 |
if(ptr == NULL)
|
sl@0
|
254 |
{
|
sl@0
|
255 |
DSOerr(DSO_F_DLFCN_BIND_VAR,DSO_R_NULL_HANDLE);
|
sl@0
|
256 |
return(NULL);
|
sl@0
|
257 |
}
|
sl@0
|
258 |
sym = dlsym(ptr, symname);
|
sl@0
|
259 |
if(sym == NULL)
|
sl@0
|
260 |
{
|
sl@0
|
261 |
DSOerr(DSO_F_DLFCN_BIND_VAR,DSO_R_SYM_FAILURE);
|
sl@0
|
262 |
ERR_add_error_data(4, "symname(", symname, "): ", dlerror());
|
sl@0
|
263 |
return(NULL);
|
sl@0
|
264 |
}
|
sl@0
|
265 |
return(sym);
|
sl@0
|
266 |
}
|
sl@0
|
267 |
|
sl@0
|
268 |
static DSO_FUNC_TYPE dlfcn_bind_func(DSO *dso, const char *symname)
|
sl@0
|
269 |
{
|
sl@0
|
270 |
void *ptr;
|
sl@0
|
271 |
DSO_FUNC_TYPE sym, *tsym = &sym;
|
sl@0
|
272 |
|
sl@0
|
273 |
if((dso == NULL) || (symname == NULL))
|
sl@0
|
274 |
{
|
sl@0
|
275 |
DSOerr(DSO_F_DLFCN_BIND_FUNC,ERR_R_PASSED_NULL_PARAMETER);
|
sl@0
|
276 |
return(NULL);
|
sl@0
|
277 |
}
|
sl@0
|
278 |
if(sk_num(dso->meth_data) < 1)
|
sl@0
|
279 |
{
|
sl@0
|
280 |
DSOerr(DSO_F_DLFCN_BIND_FUNC,DSO_R_STACK_ERROR);
|
sl@0
|
281 |
return(NULL);
|
sl@0
|
282 |
}
|
sl@0
|
283 |
ptr = (void *)sk_value(dso->meth_data, sk_num(dso->meth_data) - 1);
|
sl@0
|
284 |
if(ptr == NULL)
|
sl@0
|
285 |
{
|
sl@0
|
286 |
DSOerr(DSO_F_DLFCN_BIND_FUNC,DSO_R_NULL_HANDLE);
|
sl@0
|
287 |
return(NULL);
|
sl@0
|
288 |
}
|
sl@0
|
289 |
*(void **)(tsym) = dlsym(ptr, symname);
|
sl@0
|
290 |
if(sym == NULL)
|
sl@0
|
291 |
{
|
sl@0
|
292 |
DSOerr(DSO_F_DLFCN_BIND_FUNC,DSO_R_SYM_FAILURE);
|
sl@0
|
293 |
ERR_add_error_data(4, "symname(", symname, "): ", dlerror());
|
sl@0
|
294 |
return(NULL);
|
sl@0
|
295 |
}
|
sl@0
|
296 |
return(sym);
|
sl@0
|
297 |
}
|
sl@0
|
298 |
|
sl@0
|
299 |
static char *dlfcn_merger(DSO *dso, const char *filespec1,
|
sl@0
|
300 |
const char *filespec2)
|
sl@0
|
301 |
{
|
sl@0
|
302 |
char *merged;
|
sl@0
|
303 |
|
sl@0
|
304 |
if(!filespec1 && !filespec2)
|
sl@0
|
305 |
{
|
sl@0
|
306 |
DSOerr(DSO_F_DLFCN_MERGER,
|
sl@0
|
307 |
ERR_R_PASSED_NULL_PARAMETER);
|
sl@0
|
308 |
return(NULL);
|
sl@0
|
309 |
}
|
sl@0
|
310 |
/* If the first file specification is a rooted path, it rules.
|
sl@0
|
311 |
same goes if the second file specification is missing. */
|
sl@0
|
312 |
if (!filespec2 || filespec1[0] == '/')
|
sl@0
|
313 |
{
|
sl@0
|
314 |
merged = OPENSSL_malloc(strlen(filespec1) + 1);
|
sl@0
|
315 |
if(!merged)
|
sl@0
|
316 |
{
|
sl@0
|
317 |
DSOerr(DSO_F_DLFCN_MERGER,
|
sl@0
|
318 |
ERR_R_MALLOC_FAILURE);
|
sl@0
|
319 |
return(NULL);
|
sl@0
|
320 |
}
|
sl@0
|
321 |
strcpy(merged, filespec1);
|
sl@0
|
322 |
}
|
sl@0
|
323 |
/* If the first file specification is missing, the second one rules. */
|
sl@0
|
324 |
else if (!filespec1)
|
sl@0
|
325 |
{
|
sl@0
|
326 |
merged = OPENSSL_malloc(strlen(filespec2) + 1);
|
sl@0
|
327 |
if(!merged)
|
sl@0
|
328 |
{
|
sl@0
|
329 |
DSOerr(DSO_F_DLFCN_MERGER,
|
sl@0
|
330 |
ERR_R_MALLOC_FAILURE);
|
sl@0
|
331 |
return(NULL);
|
sl@0
|
332 |
}
|
sl@0
|
333 |
strcpy(merged, filespec2);
|
sl@0
|
334 |
}
|
sl@0
|
335 |
else
|
sl@0
|
336 |
/* This part isn't as trivial as it looks. It assumes that
|
sl@0
|
337 |
the second file specification really is a directory, and
|
sl@0
|
338 |
makes no checks whatsoever. Therefore, the result becomes
|
sl@0
|
339 |
the concatenation of filespec2 followed by a slash followed
|
sl@0
|
340 |
by filespec1. */
|
sl@0
|
341 |
{
|
sl@0
|
342 |
int spec2len, len;
|
sl@0
|
343 |
|
sl@0
|
344 |
spec2len = (filespec2 ? strlen(filespec2) : 0);
|
sl@0
|
345 |
len = spec2len + (filespec1 ? strlen(filespec1) : 0);
|
sl@0
|
346 |
|
sl@0
|
347 |
if(filespec2 && filespec2[spec2len - 1] == '/')
|
sl@0
|
348 |
{
|
sl@0
|
349 |
spec2len--;
|
sl@0
|
350 |
len--;
|
sl@0
|
351 |
}
|
sl@0
|
352 |
merged = OPENSSL_malloc(len + 2);
|
sl@0
|
353 |
if(!merged)
|
sl@0
|
354 |
{
|
sl@0
|
355 |
DSOerr(DSO_F_DLFCN_MERGER,
|
sl@0
|
356 |
ERR_R_MALLOC_FAILURE);
|
sl@0
|
357 |
return(NULL);
|
sl@0
|
358 |
}
|
sl@0
|
359 |
strcpy(merged, filespec2);
|
sl@0
|
360 |
merged[spec2len] = '/';
|
sl@0
|
361 |
strcpy(&merged[spec2len + 1], filespec1);
|
sl@0
|
362 |
}
|
sl@0
|
363 |
return(merged);
|
sl@0
|
364 |
}
|
sl@0
|
365 |
|
sl@0
|
366 |
static char *dlfcn_name_converter(DSO *dso, const char *filename)
|
sl@0
|
367 |
{
|
sl@0
|
368 |
char *translated;
|
sl@0
|
369 |
int len, rsize, transform;
|
sl@0
|
370 |
|
sl@0
|
371 |
len = strlen(filename);
|
sl@0
|
372 |
rsize = len + 1;
|
sl@0
|
373 |
transform = (strstr(filename, "/") == NULL);
|
sl@0
|
374 |
if(transform)
|
sl@0
|
375 |
{
|
sl@0
|
376 |
#ifndef SYMBIAN
|
sl@0
|
377 |
/* We will convert this to "%s.so" or "lib%s.so" */
|
sl@0
|
378 |
rsize += 3; /* The length of ".so" */
|
sl@0
|
379 |
if ((DSO_flags(dso) & DSO_FLAG_NAME_TRANSLATION_EXT_ONLY) == 0)
|
sl@0
|
380 |
rsize += 3; /* The length of "lib" */
|
sl@0
|
381 |
#else
|
sl@0
|
382 |
/* We will convert this to "%s.dll" or "lib%s.dll" */
|
sl@0
|
383 |
rsize += 4; /* The length of ".dll" */
|
sl@0
|
384 |
if ((DSO_flags(dso) & DSO_FLAG_NAME_TRANSLATION_EXT_ONLY) == 0)
|
sl@0
|
385 |
rsize += 3; /* The length of "lib" */
|
sl@0
|
386 |
#endif
|
sl@0
|
387 |
}
|
sl@0
|
388 |
translated = OPENSSL_malloc(rsize);
|
sl@0
|
389 |
if(translated == NULL)
|
sl@0
|
390 |
{
|
sl@0
|
391 |
DSOerr(DSO_F_DLFCN_NAME_CONVERTER,
|
sl@0
|
392 |
DSO_R_NAME_TRANSLATION_FAILED);
|
sl@0
|
393 |
return(NULL);
|
sl@0
|
394 |
}
|
sl@0
|
395 |
if(transform)
|
sl@0
|
396 |
{
|
sl@0
|
397 |
#ifndef SYMBIAN
|
sl@0
|
398 |
if ((DSO_flags(dso) & DSO_FLAG_NAME_TRANSLATION_EXT_ONLY) == 0)
|
sl@0
|
399 |
sprintf(translated, "lib%s.so", filename);
|
sl@0
|
400 |
else
|
sl@0
|
401 |
sprintf(translated, "%s.so", filename);
|
sl@0
|
402 |
#else
|
sl@0
|
403 |
if ((DSO_flags(dso) & DSO_FLAG_NAME_TRANSLATION_EXT_ONLY) == 0)
|
sl@0
|
404 |
sprintf(translated, "lib%s.dll", filename);
|
sl@0
|
405 |
else
|
sl@0
|
406 |
sprintf(translated, "%s.dll", filename);
|
sl@0
|
407 |
|
sl@0
|
408 |
#endif
|
sl@0
|
409 |
|
sl@0
|
410 |
}
|
sl@0
|
411 |
else
|
sl@0
|
412 |
sprintf(translated, "%s", filename);
|
sl@0
|
413 |
return(translated);
|
sl@0
|
414 |
}
|
sl@0
|
415 |
|
sl@0
|
416 |
#endif /* DSO_DLFCN */
|