PR_LoadLibrary for 64 bit MAC OS X ignores "./" and treats "./libname" same as "libname"

RESOLVED FIXED in 4.8

Status

RESOLVED FIXED
10 years ago
9 years ago

People

(Reporter: glenbeasley, Assigned: glenbeasley)

Tracking

other
x86
Mac OS X
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments)

(Assignee)

Description

10 years ago
Created attachment 364695 [details]
test program

64-bit Mac OS X NSPR uses the dlopen functions (declared in <dlfcn.h>) for dynamic library loading see bug 370766

On most OS's PR_LoadLibrary treats "./"  explicitly.

for Mac OS X:

   When path contains a slash (i.e. a full path or a partial path) dlopen() searches
     the following the following until it finds a compatible Mach-O file:
     $DYLD_LIBRARY_PATH (with leaf name from path ), current working directory (for par-
     tial paths), $DYLD_FALLBACK_LIBRARY_PATH (with leaf name from path ).

man dlopen
or
http://developer.apple.com/DOCUMENTATION/DeveloperTools/Reference/MachOReference/Reference/reference.html#//apple_ref/c/func/dlopen


meaning the Root Certs will be added provided ./libnssckbi.dylib is in the path not in the current directory

#0  pr_LoadLibraryByPathname (name=0x425450 "./libnssckbi.dylib", flags=1) at ../../../../pr/src/linking/prlink.c:1028
....
#9  0x001c8407 in NSS_Initialize (configdir=0x25900 ".", certPrefix=0x17ff2 "", keyPrefix=0x17ff2 "", secmodName=0x1c556 "secmod.db", flags=0) at nssinit.c:653
#10 0x0000aa78 in certutil_main (argc=4, argv=0xbffff784, initialize=1) at certutil.c:2361
#11 0x0000c5d8 in main (argc=4, argv=0xbffff784) at certutil.c:2981
(Assignee)

Updated

10 years ago
Blocks: 469738
(Assignee)

Updated

10 years ago
Summary: PR_LoadLibrary for 64 bit MAC OS X interprets "./libname" relatively → PR_LoadLibrary for 64 bit MAC OS X ignores "./" and treats "./libname" same as "libname"
(Assignee)

Comment 1

10 years ago
Created attachment 366365 [details] [diff] [review]
On Mac OS X 64 bit if a library name has a path check if path exists
Attachment #366365 - Flags: review?
(Assignee)

Updated

10 years ago
Attachment #366365 - Flags: review? → review?(wtc)

Comment 2

10 years ago
Comment on attachment 366365 [details] [diff] [review]
On Mac OS X 64 bit if a library name has a path check if path exists

r=wtc.  Some suggested changes before you check this in.

1. Use DARWIN instead of XP_MACOSX.

2. The comment should explain why you need to check the
path for existence.  Please add a concise summary of the
problem.

3. You have a typo in the comment: splash => slash.

4. You can rewrite the code like this:

    if (strchr(name, '/') == NULL ||
        PR_Access(name, PR_ACCESS_EXISTS) == PR_SUCCESS) {
        h = dlopen(name, dl_flags);
    }

5. I believe that it's also safe to call dlopen directly
if 'name' is an absolute pathname.  Could you test that?
If so, the above code becomes:

    if (name[0] == '/' || strchr(name, '/') == NULL ||
        PR_Access(name, PR_ACCESS_EXISTS) == PR_SUCCESS) {
        h = dlopen(name, dl_flags);
    }
Attachment #366365 - Flags: review?(wtc) → review+
(Assignee)

Comment 3

10 years ago
Thanks wan-teh for the review. 
Checking in prlink.c;
/cvsroot/mozilla/nsprpub/pr/src/linking/prlink.c,v  <--  prlink.c
new revision: 3.100; previous revision: 3.99
done


I tested #5 with a private test program.

export DYLD_LIBRARY_PATH=/Users/b/tip/mozilla/dist/Darwin9.6.0_DBG.OBJ/lib
./dllLoad /tmp/libnssckbi.dylib
testing /tmp/libnssckbi.dylib
ERROR Library not found with provided path
ERROR path not valid but library loaded!

Open apple Problem ID: 6702829
Status: NEW → RESOLVED
Last Resolved: 10 years ago
Resolution: --- → FIXED

Comment 4

10 years ago
Glen, thanks for submitting a bug report to Apple.
Target Milestone: --- → 4.8

Updated

9 years ago
Version: 4.8 → other
You need to log in before you can comment on or make changes to this bug.