Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YheHl-0008Jt-8N for pgsql-odbc@arkaria.postgresql.org; Mon, 13 Apr 2015 13:20:21 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YheHj-0000r8-K9 for pgsql-odbc@arkaria.postgresql.org; Mon, 13 Apr 2015 13:20:19 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YhbIa-0007kG-Oz for pgsql-odbc@postgresql.org; Mon, 13 Apr 2015 10:09:00 +0000 Received: from mail.vanboxtel.nl ([176.74.252.187]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YhbIT-0001zq-77 for pgsql-odbc@postgresql.org; Mon, 13 Apr 2015 10:08:58 +0000 Received: from [127.0.0.1] (unknown [172.28.13.10]) by mail.vanboxtel.nl (Postfix) with ESMTP id 5F30C63107; Mon, 13 Apr 2015 12:08:45 +0200 (CEST) Message-ID: <552B95AD.4010506@vanboxtel.nl> Date: Mon, 13 Apr 2015 12:08:45 +0200 From: Frank van der Aa - Vanboxtel BV User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: hlinnaka@iki.fi, pgsql-odbc@postgresql.org Subject: Re: PGSQL ODBC driver crash in CC_get_current_schema References: <5524EBEE.2090603@vanboxtel.nl> <5526CB48.60606@iki.fi> In-Reply-To: <5526CB48.60606@iki.fi> Content-Type: multipart/alternative; boundary="------------060508080106070108010806" X-Vanboxtel-MailScanner-ID: 5F30C63107.AEF6F X-Vanboxtel-MailScanner: Found to be clean X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-odbc Precedence: bulk Sender: pgsql-odbc-owner@postgresql.org This is a multi-part message in MIME format. --------------060508080106070108010806 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit 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 I 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 --------------060508080106070108010806 Content-Type: text/html; charset=windows-1252 Content-Transfer-Encoding: 8bit
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
I 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

--------------060508080106070108010806--