On VMS, the norm is still that symbols are uppercased, so for now it's better
[openssl.git] / crypto / dso / dso_dlfcn.c
index 279b37b..1a19164 100644 (file)
@@ -147,6 +147,7 @@ static int dlfcn_load(DSO *dso)
        if(ptr == NULL)
                {
                DSOerr(DSO_F_DLFCN_LOAD,DSO_R_LOAD_FAILED);
+               ERR_add_error_data(4, "filename(", filename, "): ", dlerror());
                goto err;
                }
        if(!sk_push(dso->meth_data, (char *)ptr))
@@ -214,6 +215,7 @@ static void *dlfcn_bind_var(DSO *dso, const char *symname)
        if(sym == NULL)
                {
                DSOerr(DSO_F_DLFCN_BIND_VAR,DSO_R_SYM_FAILURE);
+               ERR_add_error_data(4, "symname(", symname, "): ", dlerror());
                return(NULL);
                }
        return(sym);
@@ -244,6 +246,7 @@ static DSO_FUNC_TYPE dlfcn_bind_func(DSO *dso, const char *symname)
        if(sym == NULL)
                {
                DSOerr(DSO_F_DLFCN_BIND_FUNC,DSO_R_SYM_FAILURE);
+               ERR_add_error_data(4, "symname(", symname, "): ", dlerror());
                return(NULL);
                }
        return(sym);
@@ -252,16 +255,19 @@ static DSO_FUNC_TYPE dlfcn_bind_func(DSO *dso, const char *symname)
 static char *dlfcn_name_converter(DSO *dso, const char *filename)
        {
        char *translated;
-       int len, transform;
+       int len, rsize, transform;
 
        len = strlen(filename);
+       rsize = len + 1;
        transform = (strstr(filename, "/") == NULL);
        if(transform)
-               /* We will convert this to "lib%s.so" */
-               translated = OPENSSL_malloc(len + 7);
-       else
-               /* We will simply duplicate filename */
-               translated = OPENSSL_malloc(len + 1);
+               {
+               /* We will convert this to "%s.so" or "lib%s.so" */
+               rsize += 3;     /* The length of ".so" */
+               if ((DSO_flags(dso) & DSO_FLAG_NAME_TRANSLATION_EXT_ONLY) == 0)
+                       rsize += 3; /* The length of "lib" */
+               }
+       translated = OPENSSL_malloc(rsize);
        if(translated == NULL)
                {
                DSOerr(DSO_F_DLFCN_NAME_CONVERTER,
@@ -269,7 +275,12 @@ static char *dlfcn_name_converter(DSO *dso, const char *filename)
                return(NULL);
                }
        if(transform)
-               sprintf(translated, "lib%s.so", filename);
+               {
+               if ((DSO_flags(dso) & DSO_FLAG_NAME_TRANSLATION_EXT_ONLY) == 0)
+                       sprintf(translated, "lib%s.so", filename);
+               else
+                       sprintf(translated, "%s.so", filename);
+               }
        else
                sprintf(translated, "%s", filename);
        return(translated);