Skip to Content.
Sympa Menu

freetds - endian patch and Re: Strange server

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Chris Eleveld <ihermit2 AT yahoo.com>
  • To: TDS Development Group <freetds AT franklin.oit.unc.edu>
  • Subject: endian patch and Re: Strange server
  • Date: Tue, 22 Jan 2002 05:45:37 -0800 (PST)



below is a patch that includes what I did for the
strange serve on my network. More importantly however
are the changes for big endian platforms towards the
end with messages. The symptom I was seeing was that
errors and messages were not being handled. trackign
through the code this appeared to be happenning
because of a double endian swap. I have also had to
make some changes to the dblib call to the message
handler as it did not pass the final argument of the
line number. I will send that patch as it is rather
simple if anyone needs it.


*** freetds-0.53-orig/src/tds/token.c Sun Nov 25
19:04:17 2001
--- freetds-0.53/src/tds/token.c Fri Jan 18
14:54:07 2002
***************
*** 185,192 ****
ack =
tds_get_byte(tds);
major_ver =
tds_get_byte(tds);
minor_ver =
tds_get_byte(tds);
! tds_get_n(tds, NULL,
len-4);
! tds_get_byte(tds);
#ifdef WORDS_BIGENDIAN
/*
if (major_ver==7) {
--- 185,219 ----
ack =
tds_get_byte(tds);
major_ver =
tds_get_byte(tds);
minor_ver =
tds_get_byte(tds);
! if ((major_ver == 4)
&& (minor_ver == 6)) {
! int tlen;
! char
servname[1024];
!
! tds_get_byte(tds);
/* teeny version */
! tds_get_byte(tds);
/* tiny version */
! tlen =
tds_get_byte(tds); /* servname len */
! if (tlen >=
sizeof(servname))
! tlen =
sizeof(servname) - 1;
! tds_get_n(tds,
servname, tlen);
! servname[tlen] =
'\000';
! if
(!strcmp(servname, "OpenServer")) {
! if (ack == 0)
succeed=TDS_SUCCEED;
! }
! /* eat the rest of
the data as below */
! tds_get_n(tds,
NULL, len -
!
1/*ack*/ -
!
4/*major.minor.teeny.tiny*/ -
!
1/*servnamelen*/ -
!
tlen/*servname*/);
! } else {
! /*
! * shouldn't these
2 just be len - 3?
! * after all we
haev read 3 bytes of the
! * total length.
! */
! tds_get_n(tds,
NULL, len-4);
! tds_get_byte(tds);
! }
#ifdef WORDS_BIGENDIAN
/*
if (major_ver==7) {
***************
*** 1134,1143 ****

/* message number */
/* swap bytes on bigendian systems
(mlilback, 11/7/01) */
rc = tds_get_int(tds);
#ifdef WORDS_BIGENDIAN
! tds_swap_bytes(&rc, 4);
! #endif
tds->msg_info->msg_number = rc;

/* msg state */
--- 1161,1176 ----

/* message number */
/* swap bytes on bigendian systems
(mlilback, 11/7/01) */
+ /*
+ * we have to be careful not to double
swap here.
+ * tds_get_int will swap out bytes for
us if emul_little_endian
+ * is set. so lets not do it again
(CRE, 01/18/01)
+ */
rc = tds_get_int(tds);
#ifdef WORDS_BIGENDIAN
! if (tds->emul_little_endian)
! tds_swap_bytes(&rc, 4);
! #endif /* WORDS_BIGENDIAN */
tds->msg_info->msg_number = rc;

/* msg state */
***************
*** 1193,1199 ****
--- 1226,1241 ----
}

/* line number in the sql statement where the
problem occured */
+ /*
+ * we have to be careful not to double swap
here.
+ * tds_get_int will swap out bytes for us if
emul_little_endian
+ * is set. so lets do it again (CRE, 01/18/01)
+ */
tds->msg_info->line_number =
tds_get_smallint(tds);
+ #ifdef WORDS_BIGENDIAN
+ if (tds->emul_little_endian)
+
tds_swap_bytes(&tds->msg_info->line_number, 2);
+ #endif /* WORDS_BIGENDIAN */

if (tds->msg_info->priv_msg_type) {
rc = TDS_ERROR;




__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/




Archive powered by MHonArc 2.6.24.

Top of Page