[Opendnssec-commits] [keihatsu.kirei.se/svn/dnssec] r4150 - in trunk/OpenDNSSEC/enforcer: common ksm utils

Rickard Bellgrim rickard.bellgrim at iis.se
Mon Nov 1 12:55:30 CET 2010


Author: rb
Date: 2010-11-01 12:55:30 +0100 (Mon, 01 Nov 2010)
New Revision: 4150

Modified:
   trunk/OpenDNSSEC/enforcer/common/daemon.c
   trunk/OpenDNSSEC/enforcer/ksm/database_connection_mysql.c
   trunk/OpenDNSSEC/enforcer/utils/ksmutil.c
Log:
Fixing implementation of host and port.

To remember:
va_arg
"If there is no next argument, or if type is not compatible 
with the type of the actual next argument (as promoted 
according to the default argument promotions), random 
errors will occur."



Modified: trunk/OpenDNSSEC/enforcer/common/daemon.c
===================================================================
--- trunk/OpenDNSSEC/enforcer/common/daemon.c	2010-11-01 09:47:20 UTC (rev 4149)
+++ trunk/OpenDNSSEC/enforcer/common/daemon.c	2010-11-01 11:55:30 UTC (rev 4150)
@@ -108,15 +108,14 @@
 
     config.pidfile = NULL;
     config.program = NULL;
+    config.host = NULL;
+    config.port = NULL;
     config.user = (unsigned char *)calloc(MAX_USER_LENGTH, sizeof(char));
-    config.host = (unsigned char *)calloc(MAX_HOST_LENGTH, sizeof(char));
     config.password = (unsigned char *)calloc(MAX_PASSWORD_LENGTH, sizeof(char));
     config.schema = (unsigned char *)calloc(MAX_SCHEMA_LENGTH, sizeof(char));
-    config.port = (unsigned char *)calloc(MAX_PORT_LENGTH, sizeof(char));
     config.DSSubmitCmd = (char *)calloc(MAXPATHLEN + 1024, sizeof(char));
 
-    if (config.user == NULL || config.host == NULL || config.password == NULL || 
-          config.schema == NULL || config.port == NULL ) {
+    if (config.user == NULL || config.password == NULL || config.schema == NULL) {
         log_msg(&config, LOG_ERR, "Malloc for config struct failed");
         exit(1);
     }
@@ -243,11 +242,11 @@
     server_main(&config);
 
     /* Free stuff here (exit from sigs pass through) */
+    if (config.host) free(config.host);
+    if (config.port) free(config.port);
     free(config.user);
-    free(config.host);
     free(config.password);
     free(config.schema);
-    free(config.port);
     free(config.DSSubmitCmd);
 
     StrFree(config.username);

Modified: trunk/OpenDNSSEC/enforcer/ksm/database_connection_mysql.c
===================================================================
--- trunk/OpenDNSSEC/enforcer/ksm/database_connection_mysql.c	2010-11-01 09:47:20 UTC (rev 4149)
+++ trunk/OpenDNSSEC/enforcer/ksm/database_connection_mysql.c	2010-11-01 11:55:30 UTC (rev 4150)
@@ -93,7 +93,6 @@
  *                  the MsgLog() function.
 -*/
 
-/* TODO add mysql port to this ?*/
 int DbConnect(DB_HANDLE* dbhandle, const char* database, ...)
 {
 	MYSQL*		connection = NULL;	/* Local database handle */
@@ -124,6 +123,7 @@
         status = StrStrtoui(char_port, &port);
 
         if (status != 0) {
+            MsgLog(DBS_CONNFAIL, "Could not convert port number");
             return status;
         }
     }

Modified: trunk/OpenDNSSEC/enforcer/utils/ksmutil.c
===================================================================
--- trunk/OpenDNSSEC/enforcer/utils/ksmutil.c	2010-11-01 09:47:20 UTC (rev 4149)
+++ trunk/OpenDNSSEC/enforcer/utils/ksmutil.c	2010-11-01 11:55:30 UTC (rev 4150)
@@ -3702,7 +3702,7 @@
     }
 
     /* Finally we can do what we came here to do, connect to the database */
-    status = DbConnect(dbhandle, dbschema, host, password, user);
+    status = DbConnect(dbhandle, dbschema, host, password, user, port);
 
     /* Cleanup */
     StrFree(host);




More information about the Opendnssec-commits mailing list