Skip to Content.
Sympa Menu

freetds - Re: Endian of Protocol...

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Brian Macy <bmacy AT siterock.com>
  • To: TDS Development Group <freetds AT franklin.oit.unc.edu>
  • Subject: Re: Endian of Protocol...
  • Date: Tue, 27 Jun 2000 16:33:51 -0700


>From what I can tell...
- except for the length of the packet, multi-byte data is in *client*
byte order. I've yet to figure out how the server knows this though.
- the code in freetds/src/read.c tds_get_smallint function is wrong...
it should *always* have the LITTLE_ENDIAN behavior. My suggested
implementation follows.

TDS_SMALLINT tds_get_smallint(TDSSOCKET *tds)
{
unsigned char bytes[2];

tds_get_n(tds, bytes, 2);
return *(TDS_SMALLINT*)bytes;
}
/*
** Get a 32 int from the server
*/
TDS_INT tds_get_int(TDSSOCKET *tds)
{
unsigned char bytes[4];

tds_get_n(tds, bytes, 4);
return *(TDS_INT*)bytes;
}

- if sizeof(long) != 4 or sizeof(short) != 2, you are just screwed
outright... you can hack freetds/include/tds.h to fix some of it but I
know there are other places in the code that would need to change

- There is a bug in token.c tds_process_cancel... the status is a 2 byte
*not* 1 byte value...as such Perl DBI::finish() and ctlib ct_cancel will
be broken on big endian machines. My suggested fix follows.

int tds_process_cancel(TDSSOCKET *tds)
{
int marker, cancelled=0;

do {
marker=tds_get_byte(tds);
if (marker==TDS_DONE_TOKEN) {
TDS_SMALLINT status = tds_get_smallint(tds);
cancelled = status & 0x20;
tds_get_n(tds,NULL,6);
} else {
tds_process_default_tokens(tds,marker);
}
} while (!cancelled);
tds->state = TDS_COMPLETED;
}

Brian Macy

Justin Cragin wrote:
>
> I am acctualy having a problem related to this, I have freetds working with
> my app on linux, but when trying to run it on an ultra sparc with sol7 my
> app segfaults, I traced it to the second call of _ct_bind_data() when I am
> getting a debugging print of
> 1inside _ct_bind_data() setting colum size for 32 = -14961268
> And then I segfault on the line
>
> *((CS_SMALLINT *)curcol->colum_nullbind)=0;
>
> Is this an endian issue? If so do you know how I might fix it?
>
> thanks, justin cragin
>
> ---
> You are currently subscribed to freetds as: bmacy AT siterock.com
> To unsubscribe, forward this message to $subst('Email.Unsub')




Archive powered by MHonArc 2.6.24.

Top of Page