Bug 1354395 - Always bind symbols at load time for ctypes libraries. r?bsmedberg
When symbols are not bound at load time, missing symbols can lead to
NULL derefs or jumps to 0x0 at runtime, crashing the process running
the corresponding JS code, which is rather undesirable. So, prevent
libraries that have missing symbols to load at all through ctypes.
--- a/js/src/ctypes/Library.cpp
+++ b/js/src/ctypes/Library.cpp
@@ -143,17 +143,17 @@ Library::Create(JSContext* cx, HandleVal
pathStr->length(), pathBytes, &nbytes));
pathBytes[nbytes] = 0;
}
libSpec.value.pathname = pathBytes;
libSpec.type = PR_LibSpec_Pathname;
#endif
- PRLibrary* library = PR_LoadLibraryWithFlags(libSpec, 0);
+ PRLibrary* library = PR_LoadLibraryWithFlags(libSpec, PR_LD_NOW);
#ifndef XP_WIN
JS_free(cx, pathBytes);
#endif
if (!library) {
#define MAX_ERROR_LEN 1024
char error[MAX_ERROR_LEN] = "Cannot get error from NSPR.";