Skip to Content.
Sympa Menu

freetds - Bugreports (for real this time)

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Nat!" <nat AT mulle-kybernetik.de>
  • To: TDS Development Group <freetds AT franklin.oit.unc.edu>
  • Subject: Bugreports (for real this time)
  • Date: Mon, 26 Jun 2000 11:31:44 +0200


Hot damn! That stupid bug tracker clobbered another entry .
So without further ado, here are the bug reports by mail.


-----

The calculation for SYBVARBINARY row sizes in tds_process_result() and
friends is
incorrect, leading to memory clobbering. The code that fixes this is somewhat
like
this:

curcol->column_offset = info->row_size;
if (is_numeric_type(curcol->column_type))
{
info->row_size += sizeof(TDS_NUMERIC) + 1;
}
else
if ( ! is_blob_type(curcol->column_type))
{
info->row_size += curcol->column_size + 1;
#warning (nat) adjust for additional int
if (curcol->column_type == SYBVARBINARY)
info->row_size += sizeof( TDS_INT);
}

Actually one probably should write (curcol->column_type == SYBVARBINARY ||
curcol->column_type == SYBVARCHAR)

-----

Blob NULL handling is broken. I get on ASE11 a len == 0, when the BLOB is
NULL. This
case is easily fixed with a little bit of code like this in tds_process_row()


if (is_blob_type(curcol->column_type))
{
/* length is always 16, if not we are in trouble */
#warning (nat) if len == 0 -> is NULL
if( ! (len = tds_get_byte(tds)))
colsize = 0;
else
{
...
}

-----

In cs_ctx_alloc it is IMO negligent to not zero the memory, because ctx does
contain
callback pointers, that can lead to crashes if not initialized by client code

CS_RETCODE cs_ctx_alloc(CS_INT version, CS_CONTEXT **ctx)
{
*ctx = (CS_CONTEXT *) malloc(sizeof(CS_CONTEXT));
#warning (nat) memset was missing
memset( *ctx, 0, sizeof(CS_CONTEXT));
return CS_SUCCEED;
}

-----

To get the "rows affected" I had to patch ct_res_info this way.

CS_RETCODE ct_res_info(CS_COMMAND *cmd, CS_INT type, CS_VOID *buffer, CS_INT
buflen,
CS_INT *out_len)
{
...
case CS_ROW_COUNT:
#warning (nat) need this to get rows affected
if (resinfo)
int_val = resinfo->row_count;
else
int_val = cmd->con->tds_socket->rows_affected;

memcpy(buffer, &int_val, sizeof(CS_INT));
break;
}

----

Compilation for Power PC does not work with -DHW_BIG_ENDIAN. I had to use
-DHW_LITTLE_ENDIAN (!). But then most of the values received from TDS are
wrong and
need to be byteflipped (otherwise it works).

----

That´s about all I can think of right now. I did some minor changes througout
the
code, mostly adding "case" statements to get SYBIMAGE and SYBDECIMAL working
for me,
but nothing major.


Nat!




  • Bugreports (for real this time), Nat!, 06/26/2000

Archive powered by MHonArc 2.6.24.

Top of Page