diff options
author | David Sommerseth <dazo@users.sourceforge.net> | 2009-09-07 21:10:22 +0200 |
---|---|---|
committer | David Sommerseth <dazo@users.sourceforge.net> | 2009-09-07 21:10:22 +0200 |
commit | 66b29488a7ed5909564ed03b3e89cd0d008df09e (patch) | |
tree | 2ef1558a3c54b37b59a775f4734cb467cac183cb /plugin/eurephia.c | |
parent | 428d4fd45100c5c9b799f2fb127775b8b2382ecc (diff) | |
download | eurephia-66b29488a7ed5909564ed03b3e89cd0d008df09e.tar.gz eurephia-66b29488a7ed5909564ed03b3e89cd0d008df09e.tar.xz eurephia-66b29488a7ed5909564ed03b3e89cd0d008df09e.zip |
Moved all malloc() operations over to a calloc wrapper, malloc_nullsafe()
This also improves debugging as well, if debug logging is enabled and log level is >= 40.
Diffstat (limited to 'plugin/eurephia.c')
-rw-r--r-- | plugin/eurephia.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/plugin/eurephia.c b/plugin/eurephia.c index 518ba34..82a3097 100644 --- a/plugin/eurephia.c +++ b/plugin/eurephia.c @@ -34,9 +34,11 @@ #include <stdarg.h> #include <string.h> #include <getopt.h> +#include <assert.h> #define EUREPHIA_FWINTF /**< Include the proper eurephiaFWINTF declaration in eurephiaCTX */ #include <eurephiafw_struct.h> +#include <eurephia_nullsafe.h> #include <eurephia_context.h> #include <eurephiadb.h> #include <eurephiadb_driver.h> @@ -176,8 +178,8 @@ eurephiaCTX *eurephiaInit(const char **argv) // End of argument parsing // Prepare a context area for eurephia-auth - ctx = (eurephiaCTX *) malloc(sizeof(eurephiaCTX)+2); - memset(ctx, 0, sizeof(eurephiaCTX)+2); + ctx = (eurephiaCTX *) malloc_nullsafe(NULL, sizeof(eurephiaCTX)+2); + assert( ctx != NULL ); ctx->context_type = ECTX_PLUGIN_AUTH; // Open a log file @@ -224,8 +226,9 @@ eurephiaCTX *eurephiaInit(const char **argv) } // Get data for server_salt - which will be used for the password cache - ctx->server_salt = (char *) malloc(SIZE_PWDCACHE_SALT+2); - memset(ctx->server_salt, 0, SIZE_PWDCACHE_SALT+2); + ctx->server_salt = (char *) malloc_nullsafe(ctx, SIZE_PWDCACHE_SALT+2); + assert( ctx->server_salt != NULL ); + if( !eurephia_randstring(ctx, ctx->server_salt, SIZE_PWDCACHE_SALT) ) { eurephia_log(ctx, LOG_PANIC, 0 , "Could not get enough random data for password cache."); |