[freetds] [PATCH] Problem with VARCHAR in sybase.

James K. Lowden jklowden at freetds.org
Sun Jul 6 08:52:44 EDT 2008


Eddy Pronk wrote:
> The way I solved it for now inside libdbi right now is like this:
> 
>     case CS_CHAR_TYPE:
>     case CS_TEXT_TYPE:
>     case CS_VARCHAR_TYPE:
>     _type = DBI_TYPE_STRING;
>     datafmt->format = CS_FMT_NULLTERM;
>     ++datafmt->maxlength; /* 1 extra byte for \0 */
>     break;

That will make ct-lib happy, but I would worry the cure might be worse
than the disease.  If datafmt->maxlength represents the size of an
allocated buffer, increasing it without reallocating will write the NULL
to unallocated memory, with predictable unpredictable [sic] results.  

Looking forward to your results.  

--jkl


More information about the FreeTDS mailing list