Re: [BUGS] There is a case in which psqlodbc-09.03.0400 returns unterminated strings on Windows. - Mailing list pgsql-odbc

From Heikki Linnakangas
Subject Re: [BUGS] There is a case in which psqlodbc-09.03.0400 returns unterminated strings on Windows.
Date
Msg-id 56010956.1060108@iki.fi
Whole thread Raw
In response to [BUGS] There is a case in which psqlodbc-09.03.0400 returns unterminated strings on Windows.  (Naoya Anzai <nao-anzai@xc.jp.nec.com>)
Responses Re: [BUGS] There is a case in which psqlodbc-09.03.0400 returns unterminated strings on Windows.  (Naoya Anzai <nao-anzai@xc.jp.nec.com>)
List pgsql-odbc
On 09/16/2015 05:20 AM, Naoya Anzai wrote:
> Hi,
>
> I found a bug which psqlODBC returns a string without null-terminated when SQLFetch is executed on Windows.
> IMHO, it seems to be caused by differences of snprintf function between Windows and Linux.
> You have changed sprintf into snprintf at psqlodbc-09.03.0400 release.
> But snprintf on Windows(_snprintf) doesn't include a terminating character(\0) when a copy buffer length is less than
anoriginal buffer length; besides this returns -1. 
> Their behavior are different from that of Linux but psqlODBC does not currently make allowances for their
differences.
>
> As you can confirm this bug, I attached a program(test.cpp) which reproduces a bug.

Yep. This was already fixed in git master in January, in commit
532c0dad20087201feee3851652c114eb820311f.

We're long overdue for a release...

- Heikki


pgsql-odbc by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Re: How to fix buffer overrun in Windows x32
Next
From: "Andrus"
Date:
Subject: Re: How to fix buffer overrun in Windows x32