[freetds] assert in odbc driver for long error messages

Mark Brand mabrand at mabrand.nl
Tue Apr 17 09:35:23 EDT 2012


Hi,

It seems that a rather long error message raised from a stored procedure 
triggers an ASSERT in the FreeTDS ODBC driver:

unicode: odbc_util.c:391: odbc_set_string_flag: Assertion `dest == 
((void *)0) || dest-(SQLWCHAR*) buffer == out_len' failed.
Aborted

The attached rather primitive code illustrates the problem. The stored 
procedure is in the comment at the top.

I'm not very familiar with the code in question, but it looks to me that 
odbc_set_string_flag() is copying more than bytes than the limit imposed 
by cbBuffer, which is called cbErrorMsgMax from tdsdump_log() in 
error.c. In my debugger I see that initial_size is 1024 while out_len is 
1127 just before the ASSERT.

regards,

Mark
-------------- next part --------------
A non-text attachment was scrubbed...
Name: demo.c
Type: text/x-c++src
Size: 4508 bytes
Desc: not available
Url : http://lists.ibiblio.org/pipermail/freetds/attachments/20120417/cc49dd72/attachment.bin 


More information about the FreeTDS mailing list