Bug in ResolveOneParam()

Bug in ResolveOneParam()

am 16.07.2007 12:09:59 von Rainer Bauer

Hello,

I finally was able to track down the bug that occasionally happened when
UseServerSidePrepare was enabled: the driver is writing past allocated memory.

The bug is in ResolveOneParam(). At one point this function writes directly
into the allocated buffer query_statement> _without_ checking the
allocated size by calling enlarge_query_statement().

I have added the ENLARGE_NEWSTATEMENT() call which should take care of this
bug (see attached patch).

Rainer

Index: convert.c
============================================================ =======
RCS file: /cvsroot/psqlodbc/psqlodbc/convert.c,v
retrieving revision 1.161
diff -u -r1.161 convert.c
--- convert.c 4 Jun 2007 10:24:49 -0000 1.161
+++ convert.c 16 Jul 2007 09:52:51 -0000
@@ -3459,6 +3472,7 @@
} */
if (req_bind)
{
+ ENLARGE_NEWSTATEMENT( qb, (qb->npos+4) );
npos = qb->npos;
qb->npos += 4;
}

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Re: Bug in ResolveOneParam()

am 17.07.2007 23:34:47 von Hiroshi Inoue

Rainer Bauer wrote:
> Hello,
>
> I finally was able to track down the bug that occasionally happened when
> UseServerSidePrepare was enabled: the driver is writing past allocated memory.

> The bug is in ResolveOneParam(). At one point this function writes directly
> into the allocated buffer query_statement> _without_ checking the
> allocated size by calling enlarge_query_statement().
>
> I have added the ENLARGE_NEWSTATEMENT() call which should take care of this
> bug (see attached patch).


Sorry for the delay.
I would take care of it.

Thanks.

Hiroshi Inoue

> Rainer
>
> Index: convert.c
> ============================================================ =======
> RCS file: /cvsroot/psqlodbc/psqlodbc/convert.c,v
> retrieving revision 1.161
> diff -u -r1.161 convert.c
> --- convert.c 4 Jun 2007 10:24:49 -0000 1.161
> +++ convert.c 16 Jul 2007 09:52:51 -0000
> @@ -3459,6 +3472,7 @@
> } */
> if (req_bind)
> {
> + ENLARGE_NEWSTATEMENT( qb, (qb->npos+4) );
> npos = qb->npos;
> qb->npos += 4;
> }


---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match