Re: crash in LIBPQ_execute_query

From: "Merlin Moncure" <merlin(dot)moncure(at)rcsonline(dot)com>
To: "Scot Loach" <sloach(at)sandvine(dot)com>
Cc: <pgsql-odbc(at)postgresql(dot)org>
Subject: Re: crash in LIBPQ_execute_query
Date: 2005-09-02 12:45:36
Message-ID: 6EE64EF3AB31D5448D0007DD34EEB3417DD266@Herge.rcsinc.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-odbc

> Some of the queries we use can be very large.
> My code is crashing here:
>
> QResultClass *
> LIBPQ_execute_query(ConnectionClass *self,char *query)
> {
> QResultClass *qres;
> PGresult *pgres;
> char *ptr;
> char cmdbuffer[ERROR_MSG_LENGTH + 1];
> char errbuffer[ERROR_MSG_LENGTH + 1];
> int pos=0;
>
> strcpy(cmdbuffer,query);
>
>
> ERROR_MSG_LENGTH is 4096, my query is larger than that.
> What's the rationale here and how do we fix it? This works fine with
the
> old driver.

That code is fishy. I should be making strncpy, not strcpy, and I don't
understand why ERROR_MSG_LENGTH is used for the length. The query is
copied again (with strdup) inside QR_set_command.

IMO, it doesn't seem worthwhile to make the extra copy just to be able
to trim spaces leter.

Merlin

Browse pgsql-odbc by date

  From Date Subject
Next Message Dave Page 2005-09-02 12:57:30 Re: crash in LIBPQ_execute_query
Previous Message Scot Loach 2005-09-02 12:12:01 crash in LIBPQ_execute_query