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--