summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwtc%netscape.com <devnull@localhost>2003-02-27 03:23:00 +0000
committerwtc%netscape.com <devnull@localhost>2003-02-27 03:23:00 +0000
commitbd33afe328a59a24f6d513c8ce8bed1333cb80ad (patch)
tree1384db6619a7690bb2154f56c717989859296266
parentf9865acd4b15c905c9fa63a5c95bbcec81641b56 (diff)
downloadnspr-hg-bd33afe328a59a24f6d513c8ce8bed1333cb80ad.tar.gz
Bug 191948: a better implementation of PR_GetLibraryFilePathname for 32-bit
HP-UX. Tag: NSPRPUB_PRE_4_2_CLIENT_BRANCH
-rw-r--r--pr/src/linking/prlink.c42
1 files changed, 27 insertions, 15 deletions
diff --git a/pr/src/linking/prlink.c b/pr/src/linking/prlink.c
index f5682fd7..c70f1065 100644
--- a/pr/src/linking/prlink.c
+++ b/pr/src/linking/prlink.c
@@ -1933,26 +1933,38 @@ PR_GetLibraryFilePathname(const char *name, PRFuncPtr addr)
return NULL;
#elif defined(HPUX) && defined(USE_HPSHL)
- shl_t handle;
+ int index;
struct shl_descriptor desc;
char *result;
- handle = shl_load(name, DYNAMIC_PATH, 0L);
- if (handle == NULL) {
- PR_SetError(PR_LIBRARY_NOT_LOADED_ERROR, _MD_ERRNO());
- DLLErrorInternal(_MD_ERRNO());
- return NULL;
- }
- if (shl_gethandle_r(handle, &desc) == -1) {
- /* should not happen */
- _PR_MD_MAP_DEFAULT_ERROR(_MD_ERRNO());
- return NULL;
+ for (index = 0; shl_get_r(index, &desc) == 0; index++) {
+ if (strstr(desc.filename, name) != NULL) {
+ result = PR_Malloc(strlen(desc.filename)+1);
+ if (result != NULL) {
+ strcpy(result, desc.filename);
+ }
+ return result;
+ }
}
- result = PR_Malloc(strlen(desc.filename)+1);
- if (result != NULL) {
- strcpy(result, desc.filename);
+ /*
+ * Since the index value of a library is decremented if
+ * a library preceding it in the shared library search
+ * list was unloaded, it is possible that we missed some
+ * libraries as we went up the list. So we should go
+ * down the list to be sure that we not miss anything.
+ */
+ for (index--; index >= 0; index--) {
+ if ((shl_get_r(index, &desc) == 0)
+ && (strstr(desc.filename, name) != NULL)) {
+ result = PR_Malloc(strlen(desc.filename)+1);
+ if (result != NULL) {
+ strcpy(result, desc.filename);
+ }
+ return result;
+ }
}
- return result;
+ PR_SetError(PR_LIBRARY_NOT_LOADED_ERROR, 0);
+ return NULL;
#elif defined(HPUX) && defined(USE_DLFCN)
struct load_module_desc desc;
char *result;