aboutsummaryrefslogtreecommitdiffstats
path: root/test/shlibloadtest.c
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2016-11-03 18:48:23 +0100
committerRichard Levitte <levitte@openssl.org>2016-11-04 00:19:14 +0100
commit62dd3351a16089aedb0f1e62e3b6df371c93389c (patch)
treeaff53f7107d7077517a62a11d5e1605f1d0a7bb1 /test/shlibloadtest.c
parent00bb5504cc62693e05ff4e699f379011c55ecc84 (diff)
downloadopenssl-62dd3351a16089aedb0f1e62e3b6df371c93389c.tar.gz
Don't assume to know the shared library extension
test/shlibloadtest.c assumes all Unix style platforms use .so as shared library extension. This is not the case for Mac OS X, which uses .dylib. Instead of this, have the test recipe find out the extension from configuration data. Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1844)
Diffstat (limited to 'test/shlibloadtest.c')
-rw-r--r--test/shlibloadtest.c19
1 files changed, 3 insertions, 16 deletions
diff --git a/test/shlibloadtest.c b/test/shlibloadtest.c
index 20030d94a8..eea2e3ae1c 100644
--- a/test/shlibloadtest.c
+++ b/test/shlibloadtest.c
@@ -44,22 +44,9 @@ typedef void * SHLIB;
typedef void * SHLIB_SYM;
# define SHLIB_INIT NULL
-# define SHARED_LIBRARY_SUFFIX ".so"
-
-static int shlib_load(char *filename, SHLIB *lib)
+static int shlib_load(const char *filename, SHLIB *lib)
{
- char *tmpfile;
- size_t filenamelen = strlen(filename);
-
- /* Total length = base filename len + suffix len + 1 for NULL terminator */
- tmpfile = malloc(filenamelen + sizeof(SHARED_LIBRARY_SUFFIX) + 1);
- if (tmpfile == NULL)
- return 0;
- strcpy(tmpfile, filename);
- strcpy(tmpfile + filenamelen, SHARED_LIBRARY_SUFFIX);
-
- *lib = dlopen(tmpfile, RTLD_GLOBAL | RTLD_LAZY);
- free(tmpfile);
+ *lib = dlopen(filename, RTLD_GLOBAL | RTLD_LAZY);
if (*lib == NULL)
return 0;
@@ -90,7 +77,7 @@ typedef HINSTANCE SHLIB;
typedef void * SHLIB_SYM;
# define SHLIB_INIT 0
-static int shlib_load(char *filename, SHLIB *lib)
+static int shlib_load(const char *filename, SHLIB *lib)
{
*lib = LoadLibraryA(filename);
if (*lib == NULL)