summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorDavid Sommerseth <dazo@users.sourceforge.net>2009-09-27 16:37:28 +0200
committerDavid Sommerseth <dazo@users.sourceforge.net>2009-09-27 16:37:28 +0200
commit7974014a63fd6203598044bf2e0456319a230ead (patch)
treefcb010b531f8fcedab418a5571c16f8a66be8eb2 /utils
parent82c1708bd650602d892112c5846e685be94e8a46 (diff)
downloadeurephia-7974014a63fd6203598044bf2e0456319a230ead.tar.gz
eurephia-7974014a63fd6203598044bf2e0456319a230ead.tar.xz
eurephia-7974014a63fd6203598044bf2e0456319a230ead.zip
Fixed some memory leaks in eurephia_init, especially in error situations
Diffstat (limited to 'utils')
-rw-r--r--utils/eurephia_init.c42
1 files changed, 30 insertions, 12 deletions
diff --git a/utils/eurephia_init.c b/utils/eurephia_init.c
index 9eded5d..6acb6cd 100644
--- a/utils/eurephia_init.c
+++ b/utils/eurephia_init.c
@@ -232,6 +232,7 @@ int setup_admin_account(eurephiaCTX *ctx) {
if( node == NULL ) {
fprintf(stderr, "Could not retrieve valid data\n");
xmlFreeDoc(xmldoc);
+ xmlFreeDoc(resxml);
return 0;
}
@@ -239,9 +240,11 @@ int setup_admin_account(eurephiaCTX *ctx) {
if( (node != NULL) ) {
printf("User accounts found, aborting. eurephia is already initialised\n");
xmlFreeDoc(xmldoc);
+ xmlFreeDoc(resxml);
return 0;
}
xmlFreeDoc(xmldoc); xmldoc = NULL;
+ xmlFreeDoc(resxml); resxml = NULL;
printf("None found. Good!\n");
get_console_input(uname, 64, "Admin username: ", 0);
@@ -615,6 +618,7 @@ int main(int argc, char **argv) {
int argi = 0;
eurephiaVALUES *cfg = NULL;
eurephiaCTX *ctx = NULL;
+ int rc = 0;
static e_options argopts[] = {
{"--version", "-V", 0},
@@ -634,10 +638,13 @@ int main(int argc, char **argv) {
switch( eurephia_getopt(&argi, argc, argv, argopts) ) {
case 'V':
print_version(argv[0]);
- return 0;
+ rc = 0;
+ goto exit;
+
case 'h':
print_help(argv[0]);
- return 0;
+ rc = 0;
+ goto exit;
case 'l':
eAdd_value(NULL, cfg, "log", optargs[0]);
@@ -664,56 +671,67 @@ int main(int argc, char **argv) {
break;
default:
- return 1;
+ rc = 1;
+ goto exit;
}
}
if( eGet_value(cfg, "database_driver") == NULL ) {
fprintf(stderr, "Missing required database driver (--database-driver)\n");
- return 2;
+ rc = 2;
+ goto exit;
}
if( eGet_value(cfg, "database_params") == NULL ) {
fprintf(stderr, "Missing required database driver parameters (--database-args)\n");
- return 2;
+ rc = 2;
+ goto exit;
}
ctx = eurephiaCTX_init(NULL, 0, cfg);
if( ctx == NULL ) {
fprintf(stderr, "Failed to initialise an eurephia context.\n");
- return 3;
+ rc = 3;
+ goto exit;
}
if( !eurephia_ConnectDB(ctx, cfg) ) {
fprintf(stderr, "Failed to access the database.\n");
- return 4;
+ rc = 4;
+ goto exit;
}
if( !setup_password_params(ctx, hash_thr_min, hash_thr_max) ) {
- return 11;
+ rc = 11;
+ goto exit;
}
if( !setup_admin_account(ctx) ) {
- return 12;
+ rc = 12;
+ goto exit;
}
if( !setup_session_params(ctx) ) {
- return 13;
+ rc = 13;
+ goto exit;
}
if( !setup_attempt_limits(ctx) ) {
- return 14;
+ rc = 14;
+ goto exit;
}
#ifdef FW_IPTABLES
if( !setup_iptables(ctx) ){
- return 15;
+ rc = 15;
+ goto exit;
}
#endif
printf("\neurephia is now configured. For further changes, please use the eurephiadm utility.\n\n");
+ exit:
eFree_values(ctx, cfg);
eurephiaCTX_destroy(ctx);
return 0;