Re: ODBC SQLSetDescRec fix
Frediano Ziglio <[email protected]>
| Newsgroups | gmane.comp.db.tds.freetds |
|---|---|
| Message-ID | <[email protected]> |
2009/2/23 Amir Shamsuddin <[email protected]>: > 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 > Thanks, patch is ok. Applied to 0.64, 0.82 and CVS HEAD. You can find post release patch at http://freetds.sourceforge.net/ (updated snapshot will be generated this nigth). Regards Frediano