Skip to content

Commit 88e546b

Browse files
authored
Merge pull request #1457 from val-ms/kamathmain
Add AIX variables for the load module function to work in AIX.
2 parents 72805c5 + ea5d30a commit 88e546b

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

libclamav/others.c

+22-4
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,11 @@ static void *load_module(const char *name, const char *featurename)
166166
* We don't do this for Windows because Windows doesn't have an equivalent to LD_LIBRARY_PATH
167167
* and because LoadLibraryA() will search the executable's folder, which works for the unit tests.
168168
*/
169+
#ifdef _AIX
170+
ld_library_path = getenv("LIBPATH");
171+
#else
169172
ld_library_path = getenv("LD_LIBRARY_PATH");
173+
#endif
170174
if (NULL != ld_library_path && strlen(ld_library_path) > 0) {
171175
#define MAX_LIBRARY_PATHS 10
172176
size_t token_index;
@@ -184,8 +188,15 @@ static void *load_module(const char *name, const char *featurename)
184188
cli_dbgmsg("searching for %s, LD_LIBRARY_PATH: %s\n", featurename, tokens[token_index]);
185189

186190
for (i = 0; i < sizeof(suffixes) / sizeof(suffixes[0]); i++) {
187-
snprintf(modulename, sizeof(modulename), "%s" PATHSEP "%s%s", tokens[token_index], name, suffixes[i]);
188-
191+
#ifdef _AIX
192+
snprintf(modulename, sizeof(modulename),
193+
"%s%s(%s%s.%d)",
194+
name, ".a", name, LT_MODULE_EXT, LIBCLAMAV_MAJORVER);
195+
#else
196+
snprintf(modulename, sizeof(modulename),
197+
"%s" PATHSEP "%s%s",
198+
tokens[token_index], name, suffixes[i]);
199+
#endif
189200
rhandle = dlopen(modulename, RTLD_NOW);
190201
if (NULL != rhandle) {
191202
cli_dbgmsg("%s support loaded from %s\n", featurename, modulename);
@@ -203,8 +214,15 @@ static void *load_module(const char *name, const char *featurename)
203214
cli_dbgmsg("searching for %s, user-searchpath: %s\n", featurename, SEARCH_LIBDIR);
204215

205216
for (i = 0; i < sizeof(suffixes) / sizeof(suffixes[0]); i++) {
206-
snprintf(modulename, sizeof(modulename), "%s" PATHSEP "%s%s", SEARCH_LIBDIR, name, suffixes[i]);
207-
217+
#ifdef _AIX
218+
snprintf(modulename, sizeof(modulename),
219+
"%s%s(%s%s.%d)",
220+
name,".a",name,LT_MODULE_EXT,LIBCLAMAV_MAJORVER);
221+
#else
222+
snprintf(modulename, sizeof(modulename),
223+
"%s" PATHSEP "%s%s",
224+
SEARCH_LIBDIR, name, suffixes[i]);
225+
#endif
208226
rhandle = dlopen(modulename, RTLD_NOW);
209227
if (NULL != rhandle) {
210228
cli_dbgmsg("%s support loaded from %s\n", featurename, modulename);

0 commit comments

Comments
 (0)