Skip to Content.
Sympa Menu

freetds - hostname size limit?

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Mark J. Lilback" <mark AT lilback.com>
  • To: freetds mailing list <freetds AT franklin.oit.unc.edu>
  • Subject: hostname size limit?
  • Date: Tue, 15 Jan 2002 20:33:12 -0500


Ok, I'm getting a weird bug that I'm not positive about. This is all using TDS 4.2 on a big endian platform. The source is a bit old, but I think the same fundamental flaw is there in the current code.

I see the problem when trying to connect to a host with 34 characters. At some point during tds_send_login, tds->s gets set to zero, which screws up the connection. There are multiple lines in there that seem to have a 30 character limit, so that looks like it should be the problem. (There is no problem using the ip address.)

Now what is strange is that I'm seeing the problem happen on the following line on the tds_send_login function in login.c.
rc|=tds_put_string(tds,(unsigned char*)login->language,30); /* language */

In this case, login->language is an empty string.

Stepping through the debugger, I get to the following call:
tds_put_buf(tds, "", 30, 0);

Here's the appropriate code from write.c:

int tds_put_buf(TDSSOCKET *tds, unsigned char *buf, int dsize, int ssize)
{
char *tempbuf;
int cpsize;

tempbuf = (char *) malloc(dsize+1);
memset(tempbuf,'\0',dsize);
cpsize = ssize > dsize ? dsize : ssize;
memcpy(tempbuf,buf, cpsize);
tds_put_n(tds,(unsigned char*)tempbuf,dsize);
free(tempbuf);
return tds_put_byte(tds,cpsize);
}

I'm thinking that if ssize <= 0, then it should just return success since there is no need to do anything. Or at a minimum, don't try the memcpy with a cpsize of zero (this could be some kind of bug in memcpy, I'm not sure). The memcpy line is where I'm seeing tds->s get cleared.

Like I said, this seems like a really strange place for this problem to be resolved at. However, I'm thinking this is a bug in tds_put_buf that should get fixed.

Opinions?

--
__________________________________________________________________________
"They that can give up essential liberty
Mark J. Lilback to obtain a little temporary safety
<mark AT lilback.com> deserve neither liberty or safety."
http://www.lilback.com/ -- Benjamin Franklin



  • hostname size limit?, Mark J. Lilback, 01/15/2002

Archive powered by MHonArc 2.6.24.

Top of Page