mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-04 04:58:00 +00:00
Verify vector version and length before relying on the DSO's vector.
This commit is contained in:
parent
56caa19b5a
commit
4a9ba412bb
@ -32,7 +32,7 @@
|
||||
* may use your version of this file under either the MPL or the
|
||||
* GPL.
|
||||
*
|
||||
* $Id: loader.c,v 1.1 2000/12/27 03:20:03 nelsonb%netscape.com Exp $
|
||||
* $Id: loader.c,v 1.2 2000/12/28 03:26:29 nelsonb%netscape.com Exp $
|
||||
*/
|
||||
|
||||
#include "loader.h"
|
||||
@ -91,6 +91,9 @@ isHybrid(void)
|
||||
#error "code for this platform is missing."
|
||||
#endif
|
||||
|
||||
#define LSB(x) ((x)&0xff)
|
||||
#define MSB(x) ((x)>>8)
|
||||
|
||||
static const FREEBLVector *vector;
|
||||
|
||||
/* This function must be run only once. */
|
||||
@ -116,11 +119,17 @@ freebl_LoadDSO( void )
|
||||
if (handle) {
|
||||
void * address = PR_FindSymbol(handle, "FREEBL_GetVector");
|
||||
if (address) {
|
||||
FREEBLGetVectorFn * getVector = (FREEBLGetVectorFn *)address;
|
||||
const FREEBLVector * myVector = getVector();
|
||||
if (myVector) {
|
||||
vector = myVector;
|
||||
return PR_SUCCESS;
|
||||
FREEBLGetVectorFn * getVector = (FREEBLGetVectorFn *)address;
|
||||
const FREEBLVector * dsoVector = getVector();
|
||||
if (dsoVector) {
|
||||
unsigned short dsoVersion = dsoVector->version;
|
||||
unsigned short myVersion = FREEBL_VERSION;
|
||||
if (MSB(dsoVersion) == MSB(myVersion) &&
|
||||
LSB(dsoVersion) >= LSB(myVersion) &&
|
||||
dsoVector->length >= sizeof(FREEBLVector)) {
|
||||
vector = dsoVector;
|
||||
return PR_SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
PR_UnloadLibrary(handle);
|
||||
|
Loading…
x
Reference in New Issue
Block a user