From fvdaa@vanboxtel.nl Wed Apr 8 13:00:26 2015 Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Yfpak-00036d-R3 for pgsql-odbc@arkaria.postgresql.org; Wed, 08 Apr 2015 13:00:26 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Yfpaj-0005wU-JK for pgsql-odbc@arkaria.postgresql.org; Wed, 08 Apr 2015 13:00:25 +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 1YflhS-0004g7-B1 for pgsql-odbc@postgresql.org; Wed, 08 Apr 2015 08:51:06 +0000 Received: from mail.vanboxtel.nl ([176.74.252.187]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YflhJ-0001ly-Ga for pgsql-odbc@postgresql.org; Wed, 08 Apr 2015 08:51:04 +0000 Received: from [127.0.0.1] (unknown [172.28.13.10]) by mail.vanboxtel.nl (Postfix) with ESMTP id 3E24D632E6; Wed, 8 Apr 2015 10:50:54 +0200 (CEST) Message-ID: <5524EBEE.2090603@vanboxtel.nl> Date: Wed, 08 Apr 2015 10:50:54 +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.5.0 MIME-Version: 1.0 To: pgsql-odbc@postgresql.org Subject: PGSQL ODBC driver crash in CC_get_current_schema Content-Type: multipart/alternative; boundary="------------030903070205010602050407" X-Vanboxtel-MailScanner-ID: 3E24D632E6.ACB6A X-Vanboxtel-MailScanner: Not scanned: please contact your postmaster@vanboxtel.nl for details 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. --------------030903070205010602050407 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit 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 I www.vanboxtel.nl --------------030903070205010602050407 Content-Type: text/html; charset=windows-1252 Content-Transfer-Encoding: 8bit
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
I www.vanboxtel.nl

--------------030903070205010602050407-- From hlinnaka@iki.fi Thu Apr 9 18:56:20 2015 Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YgHci-00025N-Hf for pgsql-odbc@arkaria.postgresql.org; Thu, 09 Apr 2015 18:56:20 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YgHch-0002l4-Oa for pgsql-odbc@arkaria.postgresql.org; Thu, 09 Apr 2015 18:56:19 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YgHcg-0002kt-Oa for pgsql-odbc@postgresql.org; Thu, 09 Apr 2015 18:56:18 +0000 Received: from mail-wi0-x22c.google.com ([2a00:1450:400c:c05::22c]) by makus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1YgHcc-0005PO-Cw for pgsql-odbc@postgresql.org; Thu, 09 Apr 2015 18:56:16 +0000 Received: by wizk4 with SMTP id k4so103394567wiz.1 for ; Thu, 09 Apr 2015 11:56:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:reply-to:user-agent:mime-version:to :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=NXnyGg1PEBrGONQcZ8KI2oMdS/QzC4pJ3sk1w8y1idg=; b=bZVIszd7w6EUFAngDm+clrLvckdAumM7tXX2XPwRWhMSTilR7csjbViJAr15dN1YaY TVYpZcwcFuBn03RxdWNR+/Sh5FuPF/tM0W3AT4KtnOejbB3wvulsz/42PAcRbX51H8dO nGpWfiTTPdGT+3g+Opypomtnsej7triEV2NwGWklPJrAmUk6AU+y52OjK6XYrfrSbsEK kavQUM5ihqwYX6Ytmw476qXK4zmONx27R3n24zZ/rV6Gnk1LwoJrhZUSVfNptajpZpBF gPJSC1v24nivc9OkUSzy1LzzBjxt5zdpuTJwFF03pLrvZ3OeqlnIpebZYZJ44QU0d0n2 F/Ig== X-Received: by 10.194.133.199 with SMTP id pe7mr63788940wjb.120.1428605771676; Thu, 09 Apr 2015 11:56:11 -0700 (PDT) Received: from [192.168.1.99] (dsl-hkibrasgw1-58c38f-82.dhcp.inet.fi. [88.195.143.82]) by mx.google.com with ESMTPSA id z13sm21269837wjr.44.2015.04.09.11.56.10 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Apr 2015 11:56:10 -0700 (PDT) Message-ID: <5526CB48.60606@iki.fi> Date: Thu, 09 Apr 2015 21:56:08 +0300 From: Heikki Linnakangas Reply-To: hlinnaka@iki.fi User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.5.0 MIME-Version: 1.0 To: Frank van der Aa - Vanboxtel BV , pgsql-odbc@postgresql.org Subject: Re: PGSQL ODBC driver crash in CC_get_current_schema References: <5524EBEE.2090603@vanboxtel.nl> In-Reply-To: <5524EBEE.2090603@vanboxtel.nl> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.3 (--) 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 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 From fvdaa@vanboxtel.nl Mon Apr 13 13:20:21 2015 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-- From hlinnaka@iki.fi Thu Apr 16 07:16:45 2015 Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Yie2W-0002BZ-UJ for pgsql-odbc@arkaria.postgresql.org; Thu, 16 Apr 2015 07:16:45 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Yie2W-0006Ua-Ax for pgsql-odbc@arkaria.postgresql.org; Thu, 16 Apr 2015 07:16:44 +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 1Yie2V-0006US-QY for pgsql-odbc@postgresql.org; Thu, 16 Apr 2015 07:16:43 +0000 Received: from mail-wg0-x233.google.com ([2a00:1450:400c:c00::233]) by magus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1Yie2S-0004WS-1G for pgsql-odbc@postgresql.org; Thu, 16 Apr 2015 07:16:42 +0000 Received: by wgso17 with SMTP id o17so70740207wgs.1 for ; Thu, 16 Apr 2015 00:16:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:reply-to:user-agent:mime-version:to :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=JHGayN3RwZnvdh8Or9YaNOE6V16LT28q7Fy6pmoMV8Y=; b=M6exAWwXRr9e5jSCoTesbBj+RpHzkjd3WoIqoLCVktJ1alMQ3kxsYluSnV5oRkKqsd FDq1SbK8yt/F0a8wezVjZyF2AFmya1U8jrGWPw7W7211L370ANu6M/oxfouztXamTu9v cAk40c+wwVJWbfhtRsjYWE78L1NAbCGWBceUeQ10coHI6MIdmNEl3mkLRL0UoEXztjFU MvTT9BaAJwGmw7gLY0SsJv/jwj1CQzbM6nEUitT2yXfqG3zMOIx+WUsyJnPRXx5N4hWg FKnSrC88QU/vDUJ/Il2LLV0NAQxjBCM+ZAo8VDsCOFfVWUvY9oM1o+EBBdyjvHhDB959 sJ0Q== X-Received: by 10.194.108.9 with SMTP id hg9mr58613338wjb.68.1429168599079; Thu, 16 Apr 2015 00:16:39 -0700 (PDT) Received: from [192.168.1.99] (dsl-hkibrasgw1-58c38f-82.dhcp.inet.fi. [88.195.143.82]) by mx.google.com with ESMTPSA id yr1sm9054999wjc.37.2015.04.16.00.16.37 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Apr 2015 00:16:38 -0700 (PDT) Message-ID: <552F61D4.3020207@iki.fi> Date: Thu, 16 Apr 2015 10:16:36 +0300 From: Heikki Linnakangas Reply-To: hlinnaka@iki.fi User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.6.0 MIME-Version: 1.0 To: Frank van der Aa - Vanboxtel BV , pgsql-odbc@postgresql.org Subject: Re: PGSQL ODBC driver crash in CC_get_current_schema References: <5524EBEE.2090603@vanboxtel.nl> <5526CB48.60606@iki.fi> <552B95AD.4010506@vanboxtel.nl> In-Reply-To: <552B95AD.4010506@vanboxtel.nl> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.3 (--) 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 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