Skip to Content.
Sympa Menu

freetds - [freetds] potential bug in parsing of DSNs/connection strings with 'SERVERNAME' property in ODBC

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Bronner, Gregory" <gregory.bronner AT lehman.com>
  • To: freetds AT lists.ibiblio.org
  • Subject: [freetds] potential bug in parsing of DSNs/connection strings with 'SERVERNAME' property in ODBC
  • Date: Wed, 21 Jun 2006 10:32:12 -0400

This appears to have been reported in back in 2002, but was not fixed:

This applies to freetds 0.63 running on linux against a SYBASE ASE 12.5
database using no freetds.conf file, and a properly set SYBASE
environment variable.

I would like to use freetds with the $SYBASE/interfaces file.

I believe that the SERVERNAME property is a 'logical server name' -- not
a physical server name.

I believe that I should be able to connect using SqlDriverConnect ...
"DRIVERNAME=FreeTDS;SERVERNAME=MyLogicalServer;UID=myname;PWD=mypasswd;D
ATABASE=tempdb"



However, in the
odbc/connectparams.c file, the logic is:
1) copy the SERVERNAME entry into the connection->server_name field
2) call tds_read_conf_file to attempt to figure out the server/port
information.

This fails for two reasons:
a) the interf_file pointer is not set before this call, so it overlooks
the interfaces file
b) there is no logic to pick up the server/port information from the
$SYBASE/interfaces file after checking all of the various freetds files.

My solution (since I'm not using the various conf files) was to turn
tds_read_interfaces into an external function (put it in tds.h, remove
static from config.c) and call it (this has to be repeated in
odbc_get_dsn_info). However, I'm not sure that this is in the spirit of
the project, so I haven't attempted to commit this code.

else if (strcasecmp(option, "SERVERNAME") == 0) {
if (!reparse) {
tds_dstr_copy(&connection->server_name,
tds_dstr_cstr(&value));
tds_dstr_copy(&connection->server_name,
tds_dstr_cstr(&value));
#ifdef OLD_WAY
tds_read_conf_file(connection,
tds_dstr_cstr(&value));
#else

tds_read_interfaces(tds_dstr_cstr(&value), connection);
#endif
reparse = 1;
p = connect_string;
continue;

The danger with the code as currently written is that the current code
doesn't actually fail; it sets up a connection to the physical server
referred to by SERVERNAME on the default port.

This could be a problem if you have an interfaces file as follows:


XXX
yyy tcp 4000
YYY
yyy tcp 5000


connecting to servername YYY will give you the connection to XXX, which
is probably not what you want.


-Greg-

Gregory R. Bronner

------------------------------------------------------------------------------
This message is intended only for the personal and confidential use of the
designated recipient(s) named above. If you are not the intended recipient
of this message you are hereby notified that any review, dissemination,
distribution or copying of this message is strictly prohibited. This
communication is for information purposes only and should not be regarded as
an offer to sell or as a solicitation of an offer to buy any financial
product, an official confirmation of any transaction, or as an official
statement of Lehman Brothers. Email transmission cannot be guaranteed to be
secure or error-free. Therefore, we do not represent that this information
is complete or accurate and it should not be relied upon as such. All
information is subject to change without notice.
--------
IRS Circular 230 Disclosure:
Please be advised that any discussion of U.S. tax matters contained within
this communication (including any attachments) is not intended or written to
be used and cannot be used for the purpose of (i) avoiding U.S. tax related
penalties or (ii) promoting, marketing or recommending to another party any
transaction or matter addressed herein.





  • [freetds] potential bug in parsing of DSNs/connection strings with 'SERVERNAME' property in ODBC, Bronner, Gregory, 06/21/2006

Archive powered by MHonArc 2.6.24.

Top of Page