From: Simon McVittie Date: Fri, 20 Jan 2012 09:24:18 +0000 (+0000) Subject: Add support for forcing d0_blind_id and d0_rijndael to never be dlopen'd X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=a259975e6d26e633c5f993eff3871cb72c6fa613;p=xonotic%2Fdarkplaces.git Add support for forcing d0_blind_id and d0_rijndael to never be dlopen'd Until these libraries exist as Debian packages, we'd prefer a local copy (which might not be compatible) to never be loaded accidentally. Origin: vendor, Debian --- diff --git a/crypto.c b/crypto.c index 30f85545..7a0cc16a 100644 --- a/crypto.c +++ b/crypto.c @@ -209,6 +209,8 @@ static D0_EXPORT void (*qd0_blind_id_setmallocfuncs)(d0_malloc_t *m, d0_free_t * static D0_EXPORT void (*qd0_blind_id_setmutexfuncs)(d0_createmutex_t *c, d0_destroymutex_t *d, d0_lockmutex_t *l, d0_unlockmutex_t *u); static D0_EXPORT D0_WARN_UNUSED_RESULT D0_BOOL (*qd0_blind_id_verify_public_id)(const d0_blind_id_t *ctx, D0_BOOL *status); static D0_EXPORT D0_WARN_UNUSED_RESULT D0_BOOL (*qd0_blind_id_verify_private_id)(const d0_blind_id_t *ctx); + +#ifndef DISABLE_D0_BLIND_ID static dllfunction_t d0_blind_id_funcs[] = { {"d0_blind_id_new", (void **) &qd0_blind_id_new}, @@ -252,11 +254,15 @@ static dllfunction_t d0_blind_id_funcs[] = {"d0_blind_id_verify_private_id", (void **) &qd0_blind_id_verify_private_id}, {NULL, NULL} }; +#endif // end of d0_blind_id interface static dllhandle_t d0_blind_id_dll = NULL; static qboolean Crypto_OpenLibrary (void) { +#ifdef DISABLE_D0_BLIND_ID + return false; +#else const char* dllnames [] = { #if defined(WIN32) @@ -276,11 +282,14 @@ static qboolean Crypto_OpenLibrary (void) // Load the DLL return Sys_LoadLibrary (dllnames, &d0_blind_id_dll, d0_blind_id_funcs); +#endif } static void Crypto_CloseLibrary (void) { +#ifndef DISABLE_D0_BLIND_ID Sys_UnloadLibrary (&d0_blind_id_dll); +#endif } #endif @@ -313,6 +322,8 @@ D0_EXPORT void (*qd0_rijndael_decrypt) (const unsigned long *rk, int nrounds, #define D0_RIJNDAEL_KEYLENGTH(keybits) ((keybits)/8) #define D0_RIJNDAEL_RKLENGTH(keybits) ((keybits)/8+28) #define D0_RIJNDAEL_NROUNDS(keybits) ((keybits)/32+6) + +#ifndef DISABLE_D0_RIJNDAEL static dllfunction_t d0_rijndael_funcs[] = { {"d0_rijndael_setup_decrypt", (void **) &qd0_rijndael_setup_decrypt}, @@ -321,11 +332,15 @@ static dllfunction_t d0_rijndael_funcs[] = {"d0_rijndael_encrypt", (void **) &qd0_rijndael_encrypt}, {NULL, NULL} }; +#endif // end of d0_blind_id interface static dllhandle_t d0_rijndael_dll = NULL; static qboolean Crypto_Rijndael_OpenLibrary (void) { +#ifdef DISABLE_D0_RIJNDAEL + return false; +#else const char* dllnames [] = { #if defined(WIN32) @@ -345,11 +360,14 @@ static qboolean Crypto_Rijndael_OpenLibrary (void) // Load the DLL return Sys_LoadLibrary (dllnames, &d0_rijndael_dll, d0_rijndael_funcs); +#endif } static void Crypto_Rijndael_CloseLibrary (void) { +#ifndef DISABLE_D0_RIJNDAEL Sys_UnloadLibrary (&d0_rijndael_dll); +#endif } #endif diff --git a/makefile b/makefile index 7a4d33b0..e74cce2a 100644 --- a/makefile +++ b/makefile @@ -310,11 +310,21 @@ endif ifdef LINK_TO_D0_BLIND_ID CFLAGS_CRYPTO=-DLINK_TO_D0_BLIND_ID `pkg-config --cflags d0_blind_id` LIB_CRYPTO=`pkg-config --libs d0_blind_id` +else +ifdef DISABLE_D0_BLIND_ID +CFLAGS_CRYPTO=-DDISABLE_D0_BLIND_ID +LIB_CRYPTO= +endif endif ifdef LINK_TO_D0_RIJNDAEL CFLAGS_CRYPTO_RIJNDAEL=-DLINK_TO_D0_RIJNDAEL `pkg-config --cflags d0_rijndael` LIB_CRYPTO_RIJNDAEL=`pkg-config --libs d0_rijndael` +else +ifdef DISABLE_D0_RIJNDAEL +CFLAGS_CRYPTO_RIJNDAEL=-DDISABLE_D0_RIJNDAEL +LIB_CRYPTO_RIJNDAEL= +endif endif ifdef LINK_TO_FREETYPE2