Crash in 64 bit ODBC driver when using bookmarks

From: Paal Christof <Christof(dot)Paal(at)ncia(dot)nato(dot)int>
To: "pgsql-odbc(at)postgresql(dot)org" <pgsql-odbc(at)postgresql(dot)org>
Subject: Crash in 64 bit ODBC driver when using bookmarks
Date: 2018-10-19 12:16:33
Message-ID: 168ee54f5e0044088c596bc88bcc335e@NRDW2EX3.NR.NC3A
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-odbc

Dear Sir or Madam,

I think I have found a bug in the PostgreSQL ODBC driver (of which I am using the latest version 10_03).
I am using SQLBindCol to bind a bookmark column of type SQL_C_VARBOOKMARK.

Everything works perfectly when I compile my application in 32 bit mode and use the 32 bit ODBC driver.
With the 64 bit driver I get an instant crash (memory exception).
With logging turned on, the last entry in the mylog is the following:
[SC_Create_bookmark]3133: entering type=-2 buflen=64 buf=000000000C6AF268

I can also attach a debugger and the crash happens at the following line:
memcpy(CALC_BOOKMARK_ADDR(bookmark, offset, bind_size, bind_row), &pg_bm, cvtlen);

At that time the value of the bookmark variable is: bookmark = 0x0000000000000001 {buflen=??? buffer=??? used=??? ...}, screenshot attached.
Although it received good values when the function was called (as seen in the log), the memory got corrupted in between and it is no longer a valid pointer.
I assume this is because something is writing a 64 bit value into a buffer which is only made for a 32 bit integer.

Can you please fix the crash in the next version of the ODBC driver?

Regards,

Christof PAAL

NATO Communications and Information Agency
Service Support and Business Applications | Senior System Manager
SHAPE, B-7010 Mons, Belgium
T: 254 9446
E: christof(dot)paal(at)ncia(dot)nato(dot)int<mailto:> W: www.ncia.nato.int

Attachment Content-Type Size
psqlodbc.jpg image/jpeg 116.4 KB

Responses

Browse pgsql-odbc by date

  From Date Subject
Next Message Thiemo Kellner 2018-10-20 06:42:44 Re: What is the problem with this code?
Previous Message Igor Korot 2018-10-19 11:14:03 Fwd: What is the problem with this code?