From: | Heikki Linnakangas <hlinnaka(at)iki(dot)fi> |
---|---|
To: | Frank van der Aa - Vanboxtel BV <fvdaa(at)vanboxtel(dot)nl>, pgsql-odbc(at)postgresql(dot)org |
Subject: | Re: PGSQL ODBC driver crash in CC_get_current_schema |
Date: | 2015-04-09 18:56:08 |
Message-ID: | 5526CB48.60606@iki.fi |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-odbc |
On 04/08/2015 11:50 AM, Frank van der Aa - Vanboxtel BV wrote:
> Hi,
>
> we are using the PostgreSQL 9.2.4 with ODBC driver 09.03.0400.
>
> We experience a driver crash when, for some reason (e.g. insufficient
> permissions), there is no schema set.
>
> This happens because the strdup in the CC_get_current_schema function in
> connection.c is executed while the 'select current_schema()' query
> returned NULL.
>
> We have created a patch to workaround the strdup when the result of
> QR_get_value_backend_text is NULL:
>
> # diff connection.c.orig connection.c
> 4073c4073,4081
> < conn->current_schema =
> strdup(QR_get_value_backend_text(res, 0, 0));
> ---
> > {
> > const char* value =
> QR_get_value_backend_text(res, 0, 0);
> >
> > if (value == NULL)
> > conn->current_schema = NULL;
> > else
> > conn->current_schema = strdup(value);
> >
> > }
>
> We have tested this patch in our environment and didn't experience any
> problems. However, we don't oversee the entire code, but expect this not
> to give any more problems.
Hmm. That's not a very complete fix. Not all of the callers of
CC_get_current_schema() check for a NULL, so you'll still get a segfault
in the caller in some cases. Also, the NULL current_schema value should
be cached like a valid value, otherwise the driver will call
current_schema() repeatedly.
Committed. I did those additional fixes, and added a test case to the
regression suite. Thanks for the report!
- Heikki
From | Date | Subject | |
---|---|---|---|
Next Message | Lindsay Stevens | 2015-04-10 16:16:46 | Re: Re: Is it possible to set psql connection parameters before an ODBC connection? |
Previous Message | Frank van der Aa - Vanboxtel BV | 2015-04-08 08:50:54 | PGSQL ODBC driver crash in CC_get_current_schema |