[asterisk-addons-commits] tilghman: trunk r586 - /trunk/cdr/cdr_addon_mysql.c

SVN commits to the Asterisk addons project asterisk-addons-commits at lists.digium.com
Sun May 4 22:37:10 CDT 2008


Author: tilghman
Date: Sun May  4 22:37:10 2008
New Revision: 586

URL: http://svn.digium.com/view/asterisk-addons?view=rev&rev=586
Log:
If you pass NULL as the default to my_load_config_string(), you get a string of
"(null)", which is NOT zero-length, and so things succeed where they should
fail.
(Closes issue #12580)
Reported by: pnlarsson
 Patches: 
       cdr_addon_mysql.c.patch uploaded by pnlarsson (license 79)
 Tested by: mvanbaak

Modified:
    trunk/cdr/cdr_addon_mysql.c

Modified: trunk/cdr/cdr_addon_mysql.c
URL: http://svn.digium.com/view/asterisk-addons/trunk/cdr/cdr_addon_mysql.c?view=diff&rev=586&r1=585&r2=586
==============================================================================
--- trunk/cdr/cdr_addon_mysql.c (original)
+++ trunk/cdr/cdr_addon_mysql.c Sun May  4 22:37:10 2008
@@ -460,13 +460,13 @@
 	res |= my_load_config_string(cfg, "global", "hostname",  &hostname, "localhost");
 	res |= my_load_config_string(cfg, "global", "dbname", &dbname, "astriskcdrdb");
 	res |= my_load_config_string(cfg, "global", "user", &dbuser, "root");
-	res |= my_load_config_string(cfg, "global", "sock", &dbsock, NULL);
+	res |= my_load_config_string(cfg, "global", "sock", &dbsock, "");
 	res |= my_load_config_string(cfg, "global", "table", &dbtable, "cdr");
 	res |= my_load_config_string(cfg, "global", "password", &password, "");
 
-	res |= my_load_config_string(cfg, "global", "ssl_ca", &ssl_ca, NULL);
-	res |= my_load_config_string(cfg, "global", "ssl_cert", &ssl_cert, NULL);
-	res |= my_load_config_string(cfg, "global", "ssl_key", &ssl_key, NULL);
+	res |= my_load_config_string(cfg, "global", "ssl_ca", &ssl_ca, "");
+	res |= my_load_config_string(cfg, "global", "ssl_cert", &ssl_cert, "");
+	res |= my_load_config_string(cfg, "global", "ssl_key", &ssl_key, "");
 
 	res |= my_load_config_number(cfg, "global", "port", &dbport, 0);
 	res |= my_load_config_number(cfg, "global", "timeout", &timeout, 0);
@@ -522,11 +522,11 @@
 	}
 #endif
 
-	if (ssl_ca || ssl_cert || ssl_key) {
+	if ((ssl_ca && !ast_strlen_zero(ssl_ca->str)) || (ssl_cert && !ast_strlen_zero(ssl_cert->str)) || (ssl_key && !ast_strlen_zero(ssl_key->str))) {
 		mysql_ssl_set (&mysql, ssl_key->str, ssl_cert->str, ssl_ca->str, NULL, NULL);
 	}
 	temp = dbsock && !ast_strlen_zero(dbsock->str) ? dbsock->str : NULL;
-	if (!mysql_real_connect(&mysql, hostname->str, dbuser->str, password->str, dbname->str, dbport, temp, ssl_ca ? CLIENT_SSL : 0)) {
+	if (!mysql_real_connect(&mysql, hostname->str, dbuser->str, password->str, dbname->str, dbport, temp, ssl_ca && !ast_strlen_zero(ssl_ca->str) ? CLIENT_SSL : 0)) {
 		ast_log(LOG_ERROR, "Failed to connect to mysql database %s on %s.\n", dbname->str, hostname->str);
 		connected = 0;
 		records = 0;




More information about the asterisk-addons-commits mailing list