Skip to Content.
Sympa Menu

freetds - [freetds] ODBC SQLSetDescRec fix

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Amir Shamsuddin <amirs2+freetds AT gmail.com>
  • To: freetds AT lists.ibiblio.org
  • Subject: [freetds] ODBC SQLSetDescRec fix
  • Date: Mon, 23 Feb 2009 15:24:20 +0000

Hi,
I'm using freeTDS with sqlapi and using the odbc interface as recommended by
sqlapi to connect to a MSSQL server.

My program was crashing, so I tracked the issue back to a call made from
sqlapi to the freeTDS SQLSetDescRec method. It seems that sqlapi and freetds
disagree over the meaning of the nRecordNumber parameter, with sqlapi
starting indexing at 1 and freetds starting at 0, with the end result that
memory past the end of desc->records was being written to (and thus causing
the crash).

Looking at the MSDN ODBC reference
http://msdn.microsoft.com/en-us/library/ms714675(VS.85).aspx it looks to me
that nRecordNumber should start indexing at 1, with an index of 0 being
reserved for the 'bookmark record', though I'm not sure what the bookmark
record is....

so I modified freeTDS to adjust the offset before accessing the
desc->records array (very simple patch attached) and this fixed my problem.

hopefully this is a real bug report / patch and is helpful to you,

regards,

Amir

PS I'm using freeTDS version 0.64, but the patch is against current CVS
which still appears to have the same problem

--
Amir Shamsuddin

Attachment: setDescRec.patch
Description: Binary data




Archive powered by MHonArc 2.6.24.

Top of Page