Oops! Remove junk...
[openssl.git] / crypto / dso / dso_lib.c
index e7ddfd5ecf799ef0352ecd4907d8c8ce89651edf..f4d148c24ad3a0030f966737c34cb887c0041d19 100644 (file)
@@ -383,7 +383,7 @@ int DSO_set_filename(DSO *dso, const char *filename)
                DSOerr(DSO_F_DSO_SET_FILENAME,ERR_R_MALLOC_FAILURE);
                return(0);
                }
-       strcpy(copied, filename);
+       BUF_strlcpy(copied, filename, strlen(filename) + 1);
        if(dso->filename)
                OPENSSL_free(dso->filename);
        dso->filename = copied;
@@ -394,7 +394,7 @@ char *DSO_merge(DSO *dso, const char *filespec1, const char *filespec2)
        {
        char *result = NULL;
 
-       if(dso == NULL || dir == NULL)
+       if(dso == NULL || filespec1 == NULL)
                {
                DSOerr(DSO_F_DSO_MERGE,ERR_R_PASSED_NULL_PARAMETER);
                return(NULL);
@@ -403,7 +403,7 @@ char *DSO_merge(DSO *dso, const char *filespec1, const char *filespec2)
                filespec1 = dso->filename;
        if(filespec1 == NULL)
                {
-               DSOerr(DSO_F_DSO_MERGE,DSO_R_NO_FILENAME);
+               DSOerr(DSO_F_DSO_MERGE,DSO_R_NO_FILE_SPECIFICATION);
                return(NULL);
                }
        if((dso->flags & DSO_FLAG_NO_NAME_TRANSLATION) == 0)
@@ -449,7 +449,7 @@ char *DSO_convert_filename(DSO *dso, const char *filename)
                                        ERR_R_MALLOC_FAILURE);
                        return(NULL);
                        }
-               strcpy(result, filename);
+               BUF_strlcpy(result, filename, strlen(filename) + 1);
                }
        return(result);
        }
@@ -464,3 +464,35 @@ const char *DSO_get_loaded_filename(DSO *dso)
                }
        return(dso->loaded_filename);
        }
+
+int DSO_pathbyaddr(void *addr,char *path,int sz)
+       {
+       DSO_METHOD *meth = default_DSO_meth;
+       if (meth == NULL) meth = DSO_METHOD_openssl();
+       if (meth->pathbyaddr == NULL)
+               {
+               DSOerr(DSO_F_PATHBYADDR,DSO_R_UNSUPPORTED);
+               return -1;
+               }
+       return (*meth->pathbyaddr)(addr,path,sz);
+       }
+
+/* This function should be used with caution! It looks up symbols in
+ * *all* loaded modules and if module gets unloaded by somebody else
+ * attempt to dereference the pointer is doomed to have fatal
+ * consequences. Primary usage for this function is to probe *core*
+ * system functionality, e.g. check if getnameinfo(3) is available
+ * at run-time without bothering about OS-specific details such as
+ * libc.so.versioning or where does it actually reside: in libc
+ * itself or libsocket. */
+DSO_FUNC_TYPE DSO_global_lookup_func(const char *name)
+       {
+       DSO_METHOD *meth = default_DSO_meth;
+       if (meth == NULL) meth = DSO_METHOD_openssl();
+       if (meth->globallookup == NULL)
+               {
+               DSOerr(DSO_F_GLOBAL_LOOKUP_FUNC,DSO_R_UNSUPPORTED);
+               return NULL;
+               }
+       return (*meth->globallookup)(name);
+       }