pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
PGSQL ODBC driver crash in CC_get_current_schema
4+ messages / 2 participants
[nested] [flat]

* PGSQL ODBC driver crash in CC_get_current_schema
@ 2015-04-08 08:50 Frank van der Aa - Vanboxtel BV <fvdaa@vanboxtel.nl>
  2015-04-09 18:56 ` Re: PGSQL ODBC driver crash in CC_get_current_schema Heikki Linnakangas <hlinnaka@iki.fi>
  0 siblings, 1 reply; 4+ messages in thread

From: Frank van der Aa - Vanboxtel BV @ 2015-04-08 08:50 UTC (permalink / raw)
  To: pgsql-odbc

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.

Would you be able to include this patch in the next release of the ODBC 
driver? Feel free to contact in case of any questions.

-- 
Met vriendelijke groeten / Kind regards,

Frank van der Aa

Vanboxtel BV

T 	+31 (0) 492 327 333
F 	+31 (0) 492 324 326
E 	fvdaa@vanboxtel.nl <mailto:fvdaa@vanboxtel.nl>
I 	www.vanboxtel.nl <http://www.vanboxtel.nl/;

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: PGSQL ODBC driver crash in CC_get_current_schema
  2015-04-08 08:50 PGSQL ODBC driver crash in CC_get_current_schema Frank van der Aa - Vanboxtel BV <fvdaa@vanboxtel.nl>
@ 2015-04-09 18:56 ` Heikki Linnakangas <hlinnaka@iki.fi>
  2015-04-13 10:08   ` Re: PGSQL ODBC driver crash in CC_get_current_schema Frank van der Aa - Vanboxtel BV <fvdaa@vanboxtel.nl>
  0 siblings, 1 reply; 4+ messages in thread

From: Heikki Linnakangas @ 2015-04-09 18:56 UTC (permalink / raw)
  To: Frank van der Aa - Vanboxtel BV <fvdaa@vanboxtel.nl>; 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



-- 
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: PGSQL ODBC driver crash in CC_get_current_schema
  2015-04-08 08:50 PGSQL ODBC driver crash in CC_get_current_schema Frank van der Aa - Vanboxtel BV <fvdaa@vanboxtel.nl>
  2015-04-09 18:56 ` Re: PGSQL ODBC driver crash in CC_get_current_schema Heikki Linnakangas <hlinnaka@iki.fi>
@ 2015-04-13 10:08   ` Frank van der Aa - Vanboxtel BV <fvdaa@vanboxtel.nl>
  2015-04-16 07:16     ` Re: PGSQL ODBC driver crash in CC_get_current_schema Heikki Linnakangas <hlinnaka@iki.fi>
  0 siblings, 1 reply; 4+ messages in thread

From: Frank van der Aa - Vanboxtel BV @ 2015-04-13 10:08 UTC (permalink / raw)
  To: hlinnaka@iki.fi; pgsql-odbc

Hi Heikki,

thank you for adding additional fixes to solve this problem.

Do you have any idea when the next official release will be that 
includes this change?

Met vriendelijke groeten / Kind regards,

Frank van der Aa

Vanboxtel BV

T 	+31 (0) 492 327 333
F 	+31 (0) 492 324 326
E 	fvdaa@vanboxtel.nl <mailto:fvdaa@vanboxtel.nl>
I 	www.vanboxtel.nl <http://www.vanboxtel.nl/;


Heikki Linnakangas schreef op 9-4-2015 om 20:56:
> 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
>


Vanboxtel BV - Kerkstraat 4 - 5427 BC Boekel - KvK 16051676

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: PGSQL ODBC driver crash in CC_get_current_schema
  2015-04-08 08:50 PGSQL ODBC driver crash in CC_get_current_schema Frank van der Aa - Vanboxtel BV <fvdaa@vanboxtel.nl>
  2015-04-09 18:56 ` Re: PGSQL ODBC driver crash in CC_get_current_schema Heikki Linnakangas <hlinnaka@iki.fi>
  2015-04-13 10:08   ` Re: PGSQL ODBC driver crash in CC_get_current_schema Frank van der Aa - Vanboxtel BV <fvdaa@vanboxtel.nl>
@ 2015-04-16 07:16     ` Heikki Linnakangas <hlinnaka@iki.fi>
  0 siblings, 0 replies; 4+ messages in thread

From: Heikki Linnakangas @ 2015-04-16 07:16 UTC (permalink / raw)
  To: Frank van der Aa - Vanboxtel BV <fvdaa@vanboxtel.nl>; pgsql-odbc

On 04/13/2015 01:08 PM, Frank van der Aa - Vanboxtel BV wrote:
> Do you have any idea when the next official release will be that
> includes this change?

No idea. We are long overdue for a release...

- Heikki



-- 
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2015-04-16 07:16 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2015-04-08 08:50 PGSQL ODBC driver crash in CC_get_current_schema Frank van der Aa - Vanboxtel BV <fvdaa@vanboxtel.nl>
2015-04-09 18:56 ` Heikki Linnakangas <hlinnaka@iki.fi>
2015-04-13 10:08   ` Frank van der Aa - Vanboxtel BV <fvdaa@vanboxtel.nl>
2015-04-16 07:16     ` Heikki Linnakangas <hlinnaka@iki.fi>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox