[freetds] port setting in the global section of the config file does not work

Christos Zoulas christos at zoulas.com
Thu Jun 17 15:13:06 EDT 2004


Hello,

Here's a bug fix for the configuration parsing code. In the following
scenario:
	1. host not specified in the configuration file
	2. port specified in the global section of the configuration file

The code just went and trashed the connection port with 4000 or 1433.
The following fix changes that. I.e. if there is a global setting for
the port number, we use this instead of the 4000/1433. This can get
overriden by the environment setting.

christos

Index: config.c
===================================================================
RCS file: /src/twosigma/cvsroot/pub/devel/freetds/src/tds/config.c,v
retrieving revision 1.9
diff -u -u -r1.9 config.c
--- config.c	17 Jun 2004 18:55:49 -0000	1.9
+++ config.c	17 Jun 2004 19:09:11 -0000
@@ -950,11 +950,23 @@
 		 * Make a guess about the port number
 		 */
 
+		if (connection->port == 0) {
+			/*
+			 * Not set in the [global] section of the
+			 * configure file, take a guess.
+			 */
 #ifdef TDS50
-		ip_port = 4000;
+			ip_port = 4000;
 #else
-		ip_port = 1433;
+			ip_port = 1433;
 #endif
+		} else {
+			/*
+			 * Preserve setting from the [global] section
+			 * of the configure file.
+			 */
+			ip_port = connection->port;
+		}
 		if ((env_port = getenv("TDSPORT")) != NULL) {
 			ip_port = tds_lookup_port(env_port);
 			tdsdump_log(TDS_DBG_INFO1, "%L Setting 'ip_port' to %s from $TDSPORT.\n", env_port);



More information about the FreeTDS mailing list