summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/dso/dso_lib.c
diff options
context:
space:
mode:
authorjsing <>2014-04-19 15:30:17 +0000
committerjsing <>2014-04-19 15:30:17 +0000
commit0a43bea89e0285d9ce122b7667deb6dd63a538bc (patch)
treeb0d6274ec32688bdc199306377573bd7e338434e /src/lib/libcrypto/dso/dso_lib.c
parent95cc7a0a73a603d894a1891c0e90a97e05e9fa88 (diff)
downloadopenbsd-0a43bea89e0285d9ce122b7667deb6dd63a538bc.tar.gz
openbsd-0a43bea89e0285d9ce122b7667deb6dd63a538bc.tar.bz2
openbsd-0a43bea89e0285d9ce122b7667deb6dd63a538bc.zip
KNF.
Diffstat (limited to 'src/lib/libcrypto/dso/dso_lib.c')
-rw-r--r--src/lib/libcrypto/dso/dso_lib.c562
1 files changed, 274 insertions, 288 deletions
diff --git a/src/lib/libcrypto/dso/dso_lib.c b/src/lib/libcrypto/dso/dso_lib.c
index 2f77242d47..1ee4e45dce 100644
--- a/src/lib/libcrypto/dso/dso_lib.c
+++ b/src/lib/libcrypto/dso/dso_lib.c
@@ -10,7 +10,7 @@
10 * are met: 10 * are met:
11 * 11 *
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 14 *
15 * 2. Redistributions in binary form must reproduce the above copyright 15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in 16 * notice, this list of conditions and the following disclaimer in
@@ -63,230 +63,223 @@
63 63
64static DSO_METHOD *default_DSO_meth = NULL; 64static DSO_METHOD *default_DSO_meth = NULL;
65 65
66DSO *DSO_new(void) 66DSO *
67 { 67DSO_new(void)
68 return(DSO_new_method(NULL)); 68{
69 } 69 return (DSO_new_method(NULL));
70}
70 71
71void DSO_set_default_method(DSO_METHOD *meth) 72void
72 { 73DSO_set_default_method(DSO_METHOD *meth)
74{
73 default_DSO_meth = meth; 75 default_DSO_meth = meth;
74 } 76}
75 77
76DSO_METHOD *DSO_get_default_method(void) 78DSO_METHOD *
77 { 79DSO_get_default_method(void)
78 return(default_DSO_meth); 80{
79 } 81 return (default_DSO_meth);
80 82}
81DSO_METHOD *DSO_get_method(DSO *dso) 83
82 { 84DSO_METHOD *
83 return(dso->meth); 85DSO_get_method(DSO *dso)
84 } 86{
85 87 return (dso->meth);
86DSO_METHOD *DSO_set_method(DSO *dso, DSO_METHOD *meth) 88}
87 { 89
90DSO_METHOD *
91DSO_set_method(DSO *dso, DSO_METHOD *meth)
92{
88 DSO_METHOD *mtmp; 93 DSO_METHOD *mtmp;
94
89 mtmp = dso->meth; 95 mtmp = dso->meth;
90 dso->meth = meth; 96 dso->meth = meth;
91 return(mtmp); 97 return (mtmp);
92 } 98}
93 99
94DSO *DSO_new_method(DSO_METHOD *meth) 100DSO *
95 { 101DSO_new_method(DSO_METHOD *meth)
102{
96 DSO *ret; 103 DSO *ret;
97 104
98 if(default_DSO_meth == NULL) 105 if (default_DSO_meth == NULL)
99 /* We default to DSO_METH_openssl() which in turn defaults 106 /* We default to DSO_METH_openssl() which in turn defaults
100 * to stealing the "best available" method. Will fallback 107 * to stealing the "best available" method. Will fallback
101 * to DSO_METH_null() in the worst case. */ 108 * to DSO_METH_null() in the worst case. */
102 default_DSO_meth = DSO_METHOD_openssl(); 109 default_DSO_meth = DSO_METHOD_openssl();
103 ret = (DSO *)malloc(sizeof(DSO)); 110 ret = (DSO *)malloc(sizeof(DSO));
104 if(ret == NULL) 111 if (ret == NULL) {
105 { 112 DSOerr(DSO_F_DSO_NEW_METHOD, ERR_R_MALLOC_FAILURE);
106 DSOerr(DSO_F_DSO_NEW_METHOD,ERR_R_MALLOC_FAILURE); 113 return (NULL);
107 return(NULL); 114 }
108 }
109 memset(ret, 0, sizeof(DSO)); 115 memset(ret, 0, sizeof(DSO));
110 ret->meth_data = sk_void_new_null(); 116 ret->meth_data = sk_void_new_null();
111 if(ret->meth_data == NULL) 117 if (ret->meth_data == NULL) {
112 {
113 /* sk_new doesn't generate any errors so we do */ 118 /* sk_new doesn't generate any errors so we do */
114 DSOerr(DSO_F_DSO_NEW_METHOD,ERR_R_MALLOC_FAILURE); 119 DSOerr(DSO_F_DSO_NEW_METHOD, ERR_R_MALLOC_FAILURE);
115 free(ret); 120 free(ret);
116 return(NULL); 121 return (NULL);
117 } 122 }
118 if(meth == NULL) 123 if (meth == NULL)
119 ret->meth = default_DSO_meth; 124 ret->meth = default_DSO_meth;
120 else 125 else
121 ret->meth = meth; 126 ret->meth = meth;
122 ret->references = 1; 127 ret->references = 1;
123 if((ret->meth->init != NULL) && !ret->meth->init(ret)) 128 if ((ret->meth->init != NULL) && !ret->meth->init(ret)) {
124 {
125 free(ret); 129 free(ret);
126 ret=NULL; 130 ret = NULL;
127 }
128 return(ret);
129 } 131 }
132 return (ret);
133}
130 134
131int DSO_free(DSO *dso) 135int
132 { 136DSO_free(DSO *dso)
133 int i; 137{
134 138 int i;
135 if(dso == NULL) 139
136 { 140 if (dso == NULL) {
137 DSOerr(DSO_F_DSO_FREE,ERR_R_PASSED_NULL_PARAMETER); 141 DSOerr(DSO_F_DSO_FREE, ERR_R_PASSED_NULL_PARAMETER);
138 return(0); 142 return (0);
139 }
140
141 i=CRYPTO_add(&dso->references,-1,CRYPTO_LOCK_DSO);
142 if(i > 0) return(1);
143
144 if((dso->meth->dso_unload != NULL) && !dso->meth->dso_unload(dso))
145 {
146 DSOerr(DSO_F_DSO_FREE,DSO_R_UNLOAD_FAILED);
147 return(0);
148 }
149
150 if((dso->meth->finish != NULL) && !dso->meth->finish(dso))
151 {
152 DSOerr(DSO_F_DSO_FREE,DSO_R_FINISH_FAILED);
153 return(0);
154 }
155
156 sk_void_free(dso->meth_data);
157 if(dso->filename != NULL)
158 free(dso->filename);
159 if(dso->loaded_filename != NULL)
160 free(dso->loaded_filename);
161
162 free(dso);
163 return(1);
164 } 143 }
165 144
166int DSO_flags(DSO *dso) 145 i = CRYPTO_add(&dso->references, -1, CRYPTO_LOCK_DSO);
167 { 146 if (i > 0)
168 return((dso == NULL) ? 0 : dso->flags); 147 return (1);
148
149 if ((dso->meth->dso_unload != NULL) && !dso->meth->dso_unload(dso)) {
150 DSOerr(DSO_F_DSO_FREE, DSO_R_UNLOAD_FAILED);
151 return (0);
169 } 152 }
170 153
154 if ((dso->meth->finish != NULL) && !dso->meth->finish(dso)) {
155 DSOerr(DSO_F_DSO_FREE, DSO_R_FINISH_FAILED);
156 return (0);
157 }
171 158
172int DSO_up_ref(DSO *dso) 159 sk_void_free(dso->meth_data);
173 { 160 if (dso->filename != NULL)
174 if (dso == NULL) 161 free(dso->filename);
175 { 162 if (dso->loaded_filename != NULL)
176 DSOerr(DSO_F_DSO_UP_REF,ERR_R_PASSED_NULL_PARAMETER); 163 free(dso->loaded_filename);
177 return(0);
178 }
179 164
180 CRYPTO_add(&dso->references,1,CRYPTO_LOCK_DSO); 165 free(dso);
181 return(1); 166 return (1);
167}
168
169int
170DSO_flags(DSO *dso)
171{
172 return ((dso == NULL) ? 0 : dso->flags);
173}
174
175
176int
177DSO_up_ref(DSO *dso)
178{
179 if (dso == NULL) {
180 DSOerr(DSO_F_DSO_UP_REF, ERR_R_PASSED_NULL_PARAMETER);
181 return (0);
182 } 182 }
183 183
184DSO *DSO_load(DSO *dso, const char *filename, DSO_METHOD *meth, int flags) 184 CRYPTO_add(&dso->references, 1, CRYPTO_LOCK_DSO);
185 { 185 return (1);
186}
187
188DSO *
189DSO_load(DSO *dso, const char *filename, DSO_METHOD *meth, int flags)
190{
186 DSO *ret; 191 DSO *ret;
187 int allocated = 0; 192 int allocated = 0;
188 193
189 if(dso == NULL) 194 if (dso == NULL) {
190 {
191 ret = DSO_new_method(meth); 195 ret = DSO_new_method(meth);
192 if(ret == NULL) 196 if (ret == NULL) {
193 { 197 DSOerr(DSO_F_DSO_LOAD, ERR_R_MALLOC_FAILURE);
194 DSOerr(DSO_F_DSO_LOAD,ERR_R_MALLOC_FAILURE);
195 goto err; 198 goto err;
196 } 199 }
197 allocated = 1; 200 allocated = 1;
198 /* Pass the provided flags to the new DSO object */ 201 /* Pass the provided flags to the new DSO object */
199 if(DSO_ctrl(ret, DSO_CTRL_SET_FLAGS, flags, NULL) < 0) 202 if (DSO_ctrl(ret, DSO_CTRL_SET_FLAGS, flags, NULL) < 0) {
200 { 203 DSOerr(DSO_F_DSO_LOAD, DSO_R_CTRL_FAILED);
201 DSOerr(DSO_F_DSO_LOAD,DSO_R_CTRL_FAILED);
202 goto err; 204 goto err;
203 }
204 } 205 }
205 else 206 } else
206 ret = dso; 207 ret = dso;
207 /* Don't load if we're currently already loaded */ 208 /* Don't load if we're currently already loaded */
208 if(ret->filename != NULL) 209 if (ret->filename != NULL) {
209 { 210 DSOerr(DSO_F_DSO_LOAD, DSO_R_DSO_ALREADY_LOADED);
210 DSOerr(DSO_F_DSO_LOAD,DSO_R_DSO_ALREADY_LOADED);
211 goto err; 211 goto err;
212 } 212 }
213 /* filename can only be NULL if we were passed a dso that already has 213 /* filename can only be NULL if we were passed a dso that already has
214 * one set. */ 214 * one set. */
215 if(filename != NULL) 215 if (filename != NULL)
216 if(!DSO_set_filename(ret, filename)) 216 if (!DSO_set_filename(ret, filename)) {
217 { 217 DSOerr(DSO_F_DSO_LOAD, DSO_R_SET_FILENAME_FAILED);
218 DSOerr(DSO_F_DSO_LOAD,DSO_R_SET_FILENAME_FAILED); 218 goto err;
219 goto err; 219 }
220 }
221 filename = ret->filename; 220 filename = ret->filename;
222 if(filename == NULL) 221 if (filename == NULL) {
223 { 222 DSOerr(DSO_F_DSO_LOAD, DSO_R_NO_FILENAME);
224 DSOerr(DSO_F_DSO_LOAD,DSO_R_NO_FILENAME);
225 goto err; 223 goto err;
226 } 224 }
227 if(ret->meth->dso_load == NULL) 225 if (ret->meth->dso_load == NULL) {
228 { 226 DSOerr(DSO_F_DSO_LOAD, DSO_R_UNSUPPORTED);
229 DSOerr(DSO_F_DSO_LOAD,DSO_R_UNSUPPORTED);
230 goto err; 227 goto err;
231 } 228 }
232 if(!ret->meth->dso_load(ret)) 229 if (!ret->meth->dso_load(ret)) {
233 { 230 DSOerr(DSO_F_DSO_LOAD, DSO_R_LOAD_FAILED);
234 DSOerr(DSO_F_DSO_LOAD,DSO_R_LOAD_FAILED);
235 goto err; 231 goto err;
236 } 232 }
237 /* Load succeeded */ 233 /* Load succeeded */
238 return(ret); 234 return (ret);
235
239err: 236err:
240 if(allocated) 237 if (allocated)
241 DSO_free(ret); 238 DSO_free(ret);
242 return(NULL); 239 return (NULL);
243 } 240}
244 241
245void *DSO_bind_var(DSO *dso, const char *symname) 242void *
246 { 243DSO_bind_var(DSO *dso, const char *symname)
244{
247 void *ret = NULL; 245 void *ret = NULL;
248 246
249 if((dso == NULL) || (symname == NULL)) 247 if ((dso == NULL) || (symname == NULL)) {
250 { 248 DSOerr(DSO_F_DSO_BIND_VAR, ERR_R_PASSED_NULL_PARAMETER);
251 DSOerr(DSO_F_DSO_BIND_VAR,ERR_R_PASSED_NULL_PARAMETER); 249 return (NULL);
252 return(NULL); 250 }
253 } 251 if (dso->meth->dso_bind_var == NULL) {
254 if(dso->meth->dso_bind_var == NULL) 252 DSOerr(DSO_F_DSO_BIND_VAR, DSO_R_UNSUPPORTED);
255 { 253 return (NULL);
256 DSOerr(DSO_F_DSO_BIND_VAR,DSO_R_UNSUPPORTED);
257 return(NULL);
258 }
259 if((ret = dso->meth->dso_bind_var(dso, symname)) == NULL)
260 {
261 DSOerr(DSO_F_DSO_BIND_VAR,DSO_R_SYM_FAILURE);
262 return(NULL);
263 }
264 /* Success */
265 return(ret);
266 } 254 }
255 if ((ret = dso->meth->dso_bind_var(dso, symname)) == NULL) {
256 DSOerr(DSO_F_DSO_BIND_VAR, DSO_R_SYM_FAILURE);
257 return (NULL);
258 }
259 /* Success */
260 return (ret);
261}
267 262
268DSO_FUNC_TYPE DSO_bind_func(DSO *dso, const char *symname) 263DSO_FUNC_TYPE
269 { 264DSO_bind_func(DSO *dso, const char *symname)
265{
270 DSO_FUNC_TYPE ret = NULL; 266 DSO_FUNC_TYPE ret = NULL;
271 267
272 if((dso == NULL) || (symname == NULL)) 268 if ((dso == NULL) || (symname == NULL)) {
273 { 269 DSOerr(DSO_F_DSO_BIND_FUNC, ERR_R_PASSED_NULL_PARAMETER);
274 DSOerr(DSO_F_DSO_BIND_FUNC,ERR_R_PASSED_NULL_PARAMETER); 270 return (NULL);
275 return(NULL);
276 }
277 if(dso->meth->dso_bind_func == NULL)
278 {
279 DSOerr(DSO_F_DSO_BIND_FUNC,DSO_R_UNSUPPORTED);
280 return(NULL);
281 }
282 if((ret = dso->meth->dso_bind_func(dso, symname)) == NULL)
283 {
284 DSOerr(DSO_F_DSO_BIND_FUNC,DSO_R_SYM_FAILURE);
285 return(NULL);
286 }
287 /* Success */
288 return(ret);
289 } 271 }
272 if (dso->meth->dso_bind_func == NULL) {
273 DSOerr(DSO_F_DSO_BIND_FUNC, DSO_R_UNSUPPORTED);
274 return (NULL);
275 }
276 if ((ret = dso->meth->dso_bind_func(dso, symname)) == NULL) {
277 DSOerr(DSO_F_DSO_BIND_FUNC, DSO_R_SYM_FAILURE);
278 return (NULL);
279 }
280 /* Success */
281 return (ret);
282}
290 283
291/* I don't really like these *_ctrl functions very much to be perfectly 284/* I don't really like these *_ctrl functions very much to be perfectly
292 * honest. For one thing, I think I have to return a negative value for 285 * honest. For one thing, I think I have to return a negative value for
@@ -296,178 +289,171 @@ DSO_FUNC_TYPE DSO_bind_func(DSO *dso, const char *symname)
296 * odd times. I'd prefer "output" values to be passed by reference and 289 * odd times. I'd prefer "output" values to be passed by reference and
297 * the return value as success/failure like usual ... but we conform 290 * the return value as success/failure like usual ... but we conform
298 * when we must... :-) */ 291 * when we must... :-) */
299long DSO_ctrl(DSO *dso, int cmd, long larg, void *parg) 292long
300 { 293DSO_ctrl(DSO *dso, int cmd, long larg, void *parg)
301 if(dso == NULL) 294{
302 { 295 if (dso == NULL) {
303 DSOerr(DSO_F_DSO_CTRL,ERR_R_PASSED_NULL_PARAMETER); 296 DSOerr(DSO_F_DSO_CTRL, ERR_R_PASSED_NULL_PARAMETER);
304 return(-1); 297 return (-1);
305 } 298 }
306 /* We should intercept certain generic commands and only pass control 299 /* We should intercept certain generic commands and only pass control
307 * to the method-specific ctrl() function if it's something we don't 300 * to the method-specific ctrl() function if it's something we don't
308 * handle. */ 301 * handle. */
309 switch(cmd) 302 switch (cmd) {
310 {
311 case DSO_CTRL_GET_FLAGS: 303 case DSO_CTRL_GET_FLAGS:
312 return dso->flags; 304 return dso->flags;
313 case DSO_CTRL_SET_FLAGS: 305 case DSO_CTRL_SET_FLAGS:
314 dso->flags = (int)larg; 306 dso->flags = (int)larg;
315 return(0); 307 return (0);
316 case DSO_CTRL_OR_FLAGS: 308 case DSO_CTRL_OR_FLAGS:
317 dso->flags |= (int)larg; 309 dso->flags |= (int)larg;
318 return(0); 310 return (0);
319 default: 311 default:
320 break; 312 break;
321 }
322 if((dso->meth == NULL) || (dso->meth->dso_ctrl == NULL))
323 {
324 DSOerr(DSO_F_DSO_CTRL,DSO_R_UNSUPPORTED);
325 return(-1);
326 }
327 return(dso->meth->dso_ctrl(dso,cmd,larg,parg));
328 } 313 }
329 314 if ((dso->meth == NULL) || (dso->meth->dso_ctrl == NULL)) {
330int DSO_set_name_converter(DSO *dso, DSO_NAME_CONVERTER_FUNC cb, 315 DSOerr(DSO_F_DSO_CTRL, DSO_R_UNSUPPORTED);
331 DSO_NAME_CONVERTER_FUNC *oldcb) 316 return (-1);
332 { 317 }
333 if(dso == NULL) 318 return (dso->meth->dso_ctrl(dso, cmd, larg, parg));
334 { 319}
320
321int
322DSO_set_name_converter(DSO *dso, DSO_NAME_CONVERTER_FUNC cb,
323 DSO_NAME_CONVERTER_FUNC *oldcb)
324{
325 if (dso == NULL) {
335 DSOerr(DSO_F_DSO_SET_NAME_CONVERTER, 326 DSOerr(DSO_F_DSO_SET_NAME_CONVERTER,
336 ERR_R_PASSED_NULL_PARAMETER); 327 ERR_R_PASSED_NULL_PARAMETER);
337 return(0); 328 return (0);
338 } 329 }
339 if(oldcb) 330 if (oldcb)
340 *oldcb = dso->name_converter; 331 *oldcb = dso->name_converter;
341 dso->name_converter = cb; 332 dso->name_converter = cb;
342 return(1); 333 return (1);
343 } 334}
344 335
345const char *DSO_get_filename(DSO *dso) 336const char *
346 { 337DSO_get_filename(DSO *dso)
347 if(dso == NULL) 338{
348 { 339 if (dso == NULL) {
349 DSOerr(DSO_F_DSO_GET_FILENAME,ERR_R_PASSED_NULL_PARAMETER); 340 DSOerr(DSO_F_DSO_GET_FILENAME, ERR_R_PASSED_NULL_PARAMETER);
350 return(NULL); 341 return (NULL);
351 }
352 return(dso->filename);
353 } 342 }
343 return (dso->filename);
344}
354 345
355int DSO_set_filename(DSO *dso, const char *filename) 346int
356 { 347DSO_set_filename(DSO *dso, const char *filename)
348{
357 char *copied; 349 char *copied;
358 350
359 if((dso == NULL) || (filename == NULL)) 351 if ((dso == NULL) || (filename == NULL)) {
360 { 352 DSOerr(DSO_F_DSO_SET_FILENAME, ERR_R_PASSED_NULL_PARAMETER);
361 DSOerr(DSO_F_DSO_SET_FILENAME,ERR_R_PASSED_NULL_PARAMETER); 353 return (0);
362 return(0); 354 }
363 } 355 if (dso->loaded_filename) {
364 if(dso->loaded_filename) 356 DSOerr(DSO_F_DSO_SET_FILENAME, DSO_R_DSO_ALREADY_LOADED);
365 { 357 return (0);
366 DSOerr(DSO_F_DSO_SET_FILENAME,DSO_R_DSO_ALREADY_LOADED); 358 }
367 return(0);
368 }
369 /* We'll duplicate filename */ 359 /* We'll duplicate filename */
370 copied = malloc(strlen(filename) + 1); 360 copied = malloc(strlen(filename) + 1);
371 if(copied == NULL) 361 if (copied == NULL) {
372 { 362 DSOerr(DSO_F_DSO_SET_FILENAME, ERR_R_MALLOC_FAILURE);
373 DSOerr(DSO_F_DSO_SET_FILENAME,ERR_R_MALLOC_FAILURE); 363 return (0);
374 return(0); 364 }
375 }
376 strlcpy(copied, filename, strlen(filename) + 1); 365 strlcpy(copied, filename, strlen(filename) + 1);
377 if(dso->filename) 366 if (dso->filename)
378 free(dso->filename); 367 free(dso->filename);
379 dso->filename = copied; 368 dso->filename = copied;
380 return(1); 369 return (1);
381 } 370}
382 371
383char *DSO_merge(DSO *dso, const char *filespec1, const char *filespec2) 372char *
384 { 373DSO_merge(DSO *dso, const char *filespec1, const char *filespec2)
374{
385 char *result = NULL; 375 char *result = NULL;
386 376
387 if(dso == NULL || filespec1 == NULL) 377 if (dso == NULL || filespec1 == NULL) {
388 { 378 DSOerr(DSO_F_DSO_MERGE, ERR_R_PASSED_NULL_PARAMETER);
389 DSOerr(DSO_F_DSO_MERGE,ERR_R_PASSED_NULL_PARAMETER); 379 return (NULL);
390 return(NULL); 380 }
391 } 381 if ((dso->flags & DSO_FLAG_NO_NAME_TRANSLATION) == 0) {
392 if((dso->flags & DSO_FLAG_NO_NAME_TRANSLATION) == 0) 382 if (dso->merger != NULL)
393 {
394 if(dso->merger != NULL)
395 result = dso->merger(dso, filespec1, filespec2); 383 result = dso->merger(dso, filespec1, filespec2);
396 else if(dso->meth->dso_merger != NULL) 384 else if (dso->meth->dso_merger != NULL)
397 result = dso->meth->dso_merger(dso, 385 result = dso->meth->dso_merger(dso,
398 filespec1, filespec2); 386 filespec1, filespec2);
399 }
400 return(result);
401 } 387 }
388 return (result);
389}
402 390
403char *DSO_convert_filename(DSO *dso, const char *filename) 391char *
404 { 392DSO_convert_filename(DSO *dso, const char *filename)
393{
405 char *result = NULL; 394 char *result = NULL;
406 395
407 if(dso == NULL) 396 if (dso == NULL) {
408 { 397 DSOerr(DSO_F_DSO_CONVERT_FILENAME, ERR_R_PASSED_NULL_PARAMETER);
409 DSOerr(DSO_F_DSO_CONVERT_FILENAME,ERR_R_PASSED_NULL_PARAMETER); 398 return (NULL);
410 return(NULL); 399 }
411 } 400 if (filename == NULL)
412 if(filename == NULL)
413 filename = dso->filename; 401 filename = dso->filename;
414 if(filename == NULL) 402 if (filename == NULL) {
415 { 403 DSOerr(DSO_F_DSO_CONVERT_FILENAME, DSO_R_NO_FILENAME);
416 DSOerr(DSO_F_DSO_CONVERT_FILENAME,DSO_R_NO_FILENAME); 404 return (NULL);
417 return(NULL); 405 }
418 } 406 if ((dso->flags & DSO_FLAG_NO_NAME_TRANSLATION) == 0) {
419 if((dso->flags & DSO_FLAG_NO_NAME_TRANSLATION) == 0) 407 if (dso->name_converter != NULL)
420 {
421 if(dso->name_converter != NULL)
422 result = dso->name_converter(dso, filename); 408 result = dso->name_converter(dso, filename);
423 else if(dso->meth->dso_name_converter != NULL) 409 else if (dso->meth->dso_name_converter != NULL)
424 result = dso->meth->dso_name_converter(dso, filename); 410 result = dso->meth->dso_name_converter(dso, filename);
425 } 411 }
426 if(result == NULL) 412 if (result == NULL) {
427 {
428 result = malloc(strlen(filename) + 1); 413 result = malloc(strlen(filename) + 1);
429 if(result == NULL) 414 if (result == NULL) {
430 {
431 DSOerr(DSO_F_DSO_CONVERT_FILENAME, 415 DSOerr(DSO_F_DSO_CONVERT_FILENAME,
432 ERR_R_MALLOC_FAILURE); 416 ERR_R_MALLOC_FAILURE);
433 return(NULL); 417 return (NULL);
434 }
435 strlcpy(result, filename, strlen(filename) + 1);
436 } 418 }
437 return(result); 419 strlcpy(result, filename, strlen(filename) + 1);
438 } 420 }
421 return (result);
422}
439 423
440const char *DSO_get_loaded_filename(DSO *dso) 424const char *
441 { 425DSO_get_loaded_filename(DSO *dso)
442 if(dso == NULL) 426{
443 { 427 if (dso == NULL) {
444 DSOerr(DSO_F_DSO_GET_LOADED_FILENAME, 428 DSOerr(DSO_F_DSO_GET_LOADED_FILENAME,
445 ERR_R_PASSED_NULL_PARAMETER); 429 ERR_R_PASSED_NULL_PARAMETER);
446 return(NULL); 430 return (NULL);
447 }
448 return(dso->loaded_filename);
449 } 431 }
432 return (dso->loaded_filename);
433}
450 434
451int DSO_pathbyaddr(void *addr,char *path,int sz) 435int
452 { 436DSO_pathbyaddr(void *addr, char *path, int sz)
437{
453 DSO_METHOD *meth = default_DSO_meth; 438 DSO_METHOD *meth = default_DSO_meth;
454 if (meth == NULL) meth = DSO_METHOD_openssl(); 439 if (meth == NULL)
455 if (meth->pathbyaddr == NULL) 440 meth = DSO_METHOD_openssl();
456 { 441 if (meth->pathbyaddr == NULL) {
457 DSOerr(DSO_F_DSO_PATHBYADDR,DSO_R_UNSUPPORTED); 442 DSOerr(DSO_F_DSO_PATHBYADDR, DSO_R_UNSUPPORTED);
458 return -1; 443 return -1;
459 }
460 return (*meth->pathbyaddr)(addr,path,sz);
461 } 444 }
445 return (*meth->pathbyaddr)(addr, path, sz);
446}
462 447
463void *DSO_global_lookup(const char *name) 448void *
464 { 449DSO_global_lookup(const char *name)
450{
465 DSO_METHOD *meth = default_DSO_meth; 451 DSO_METHOD *meth = default_DSO_meth;
466 if (meth == NULL) meth = DSO_METHOD_openssl(); 452 if (meth == NULL)
467 if (meth->globallookup == NULL) 453 meth = DSO_METHOD_openssl();
468 { 454 if (meth->globallookup == NULL) {
469 DSOerr(DSO_F_DSO_GLOBAL_LOOKUP,DSO_R_UNSUPPORTED); 455 DSOerr(DSO_F_DSO_GLOBAL_LOOKUP, DSO_R_UNSUPPORTED);
470 return NULL; 456 return NULL;
471 }
472 return (*meth->globallookup)(name);
473 } 457 }
458 return (*meth->globallookup)(name);
459}