This change to the "dl", "dlfcn", and "win32" DSO_METHODs adds the filename
[openssl.git] / crypto / dso / dso_dl.c
index 6dd1b19..a831877 100644 (file)
@@ -126,10 +126,11 @@ static int dl_load(DSO *dso)
                DSOerr(DSO_F_DL_LOAD,DSO_R_NO_FILENAME);
                goto err;
                }
-       ptr = shl_load(filename, BIND_IMMEDIATE, NULL);
+       ptr = shl_load(filename, BIND_IMMEDIATE|DYNAMIC_PATH, NULL);
        if(ptr == NULL)
                {
                DSOerr(DSO_F_DL_LOAD,DSO_R_LOAD_FAILED);
+               ERR_add_error_data(3, "filename(", filename, ")");
                goto err;
                }
        if(!sk_push(dso->meth_data, (char *)ptr))
@@ -198,6 +199,7 @@ static void *dl_bind_var(DSO *dso, const char *symname)
        if (shl_findsym(&ptr, symname, TYPE_UNDEFINED, &sym) < 0)
                {
                DSOerr(DSO_F_DL_BIND_VAR,DSO_R_SYM_FAILURE);
+               ERR_add_error_data(3, "symname(", symname, ")");
                return(NULL);
                }
        return(sym);
@@ -227,6 +229,7 @@ static DSO_FUNC_TYPE dl_bind_func(DSO *dso, const char *symname)
        if (shl_findsym(&ptr, symname, TYPE_UNDEFINED, &sym) < 0)
                {
                DSOerr(DSO_F_DL_BIND_FUNC,DSO_R_SYM_FAILURE);
+               ERR_add_error_data(3, "symname(", symname, ")");
                return(NULL);
                }
        return((DSO_FUNC_TYPE)sym);
@@ -234,22 +237,29 @@ static DSO_FUNC_TYPE dl_bind_func(DSO *dso, const char *symname)
 
 /* This function is identical to the one in dso_dlfcn.c, but as it is highly
  * unlikely that both the "dl" *and* "dlfcn" variants are being compiled at the
- * same time, there's no great duplicating the code. Figuring out an elegant way
- * to share one copy of the code would be more difficult and would not leave the
- * implementations independant. */
+ * same time, there's no great duplicating the code. Figuring out an elegant 
+ * way to share one copy of the code would be more difficult and would not
+ * leave the implementations independant. */
+#if defined(__hpux)
+static const char extension[] = ".sl";
+#else
+static const char extension[] = ".so";
+#endif
 static char *dl_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.s?" or "lib%s.s?" */
+               rsize += strlen(extension);/* The length of ".s?" */
+               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_DL_NAME_CONVERTER,
@@ -257,7 +267,12 @@ static char *dl_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%s", filename, extension);
+               else
+                       sprintf(translated, "%s%s", filename, extension);
+               }
        else
                sprintf(translated, "%s", filename);
        return(translated);