Skip to Content.
Sympa Menu

freetds - Re: [freetds] Bug in tds_set_server when coming through ct_connect

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Frediano Ziglio <freddy77 AT gmail.com>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] Bug in tds_set_server when coming through ct_connect
  • Date: Tue, 30 Nov 2010 14:29:42 +0100

Applied

freddy77

2010/11/29 Peter C. Norton <spacey-freetds.org AT ssr.com>:
> I have this bug report from a user:
>
> ct_connect is defined (in ctlib/ct.c) as:
> CS_RETCODE
> ct_connect(CS_CONNECTION * con, CS_CHAR * servername, CS_INT snamelen)
> {
>       ...
>       } else if (snamelen == 0 || snamelen == CS_UNUSED) {
>              server = NULL;
>       ...
>       tds_set_server(con->tds_login, server);
>       ...
>
> Note that 'snamelen' is explicitly and intentionally allowed to be 0,
> in which case the 'servername' is ignored and we pass in server=NULL
> to tds_set_server.
>
> In
> http://freetds.cvs.sourceforge.net/viewvc/freetds/freetds/src/tds/login.c?r1=1.178&r2=1.179&;,
> the code to default the server name based on the $TDSQUERY or $DSQUERY
> environment variables is #if'ed out and replaced by
>       assert(server);
>
> The comment says
>        // Doing this in tds_alloc_login instead
> which, while true (in tds/mem.c), does not prevent the assert from failing.
>
>
> So, can you please change it to something along the lines of
>
> -    assert(server);
> -    tds_dstr_copy(&tds_login->server_name, server);
> +    if (server != NULL) {
> +        tds_dstr_copy(&tds_login->server_name, server);
> +    }
>
>
>
> Thanks,
>
> -Peter




Archive powered by MHonArc 2.6.24.

Top of Page