Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WzBO3-0005fX-8O for pgsql-odbc@arkaria.postgresql.org; Mon, 23 Jun 2014 21:02:47 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WzBO2-0007Ey-Ol for pgsql-odbc@arkaria.postgresql.org; Mon, 23 Jun 2014 21:02:46 +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 1WzBO1-0007En-Mt for pgsql-odbc@postgresql.org; Mon, 23 Jun 2014 21:02:45 +0000 Received: from smtp-outbound-1.vmware.com ([208.91.2.12]) by makus.postgresql.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1WzBNw-0001Nz-Vt for pgsql-odbc@postgresql.org; Mon, 23 Jun 2014 21:02:42 +0000 Received: from sc9-mailhost3.vmware.com (sc9-mailhost3.vmware.com [10.113.161.73]) by smtp-outbound-1.vmware.com (Postfix) with ESMTP id A66AE29CF5 for ; Mon, 23 Jun 2014 14:02:38 -0700 (PDT) Received: from altair.prom.eng.vmware.com (unknown [10.113.229.11]) by sc9-mailhost3.vmware.com (Postfix) with ESMTP id 8524C412E1 for ; Mon, 23 Jun 2014 14:02:38 -0700 (PDT) Message-ID: <53A895EE.9040902@vmware.com> Date: Mon, 23 Jun 2014 14:02:38 -0700 From: Nikhil Deshpande User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: pgsql-odbc@postgresql.org Subject: [PATCH] Fix crash during connect using SSPI auth Content-Type: multipart/mixed; boundary="------------090300070601030706090806" X-Pg-Spam-Score: -6.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. --------------090300070601030706090806 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi, I ran into a crash in psqlodbc driver on Windows while trying to connect using SSPI authentication (both client and server are on same Windows host, using a Windows local account instead of domain account, without any Kerberos setup). The crash is due to a NULL pointer dereference in function extract_extra_attribute_setting(), ci->conn_settings.name was NULL in caller MakePrincHint(): 1741 char *extract_extra_attribute_setting(const pgNAME setting, ... 1742 { 1743 const char *str = GET_NAME(setting); ... 1750 for (cptr = str; *cptr; cptr++) <-- *cptr crashes Please see attached stack trace for more details. With attached patch, connection using SSPI authentication was successful. Thanks, Nikhil --------------090300070601030706090806 Content-Type: text/plain; charset=UTF-8; name="stacktrace.txt" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="stacktrace.txt" 00 psqlodbc35w!extract_extra_attribute_setting(struct pgNAME setting = struct pgNAME, char * attr = 0x00000001`80223bc0 "krbsrvname")+0x9b [e:\git\pg\winbuild\win64\pg\pgodbc\dlg_specific.c @ 1751] 01 psqlodbc35w!MakePrincHint(struct ConnInfo * ci = 0x00000000`01fa6160, int sspi = 0n1)+0x48 [e:\git\pg\winbuild\win64\pg\pgodbc\connection.c @ 1540] 02 psqlodbc35w!original_CC_connect(struct ConnectionClass_ * self = 0x00000000`01fa6080, char password_req = 0n0 '', char * salt_para = 0x00000000`0012ebe4 "")+0x1592 [e:\git\pg\winbuild\win64\pg\pgodbc\connection.c @ 2019] 03 psqlodbc35w!CC_connect(struct ConnectionClass_ * self = 0x00000000`01fa6080, char password_req = 0n0 '', char * salt_para = 0x00000000`0012ebe4 "")+0x17a [e:\git\pg\winbuild\win64\pg\pgodbc\connection.c @ 2165] 04 psqlodbc35w!PGAPI_DriverConnect(void * hdbc = 0x00000000`01fa6080, struct HWND__ * hwnd = 0x00000000`00010010, unsigned char * szConnStrIn = 0x00000000`01fa27d0 "DSN=sspi_dsn_test;", short cbConnStrIn = 0n22, unsigned char * szConnStrOut = 0x00000000`01fa70c0 "???", short cbConnStrOutMax = 0n2048, short * pcbConnStrOut = 0x00000000`0012ecc4, unsigned short fDriverCompletion = 0)+0x3b6 [e:\git\pg\winbuild\win64\pg\pgodbc\drvconn.c @ 229] 05 psqlodbc35w!SQLDriverConnectW(void * hdbc = 0x00000000`01fa6080, struct HWND__ * hwnd = 0x00000000`00010010, unsigned short * szConnStrIn = 0x00000000`003c4660, short cbConnStrIn = 0n-3, unsigned short * szConnStrOut = 0x00000000`0012f6c0, short cbConnStrOutMax = 0n2048, short * pcbConnStrOut = 0x00000000`0012fec0, unsigned short fDriverCompletion = 0)+0x1b6 [e:\git\pg\winbuild\win64\pg\pgodbc\odbcapiw.c @ 143] 06 ODBC32!SQLInternalDriverConnectW+0x53c 07 ODBC32!SQLDriverConnectW+0x1863 08 ODBCClientSample!getConnection(void)+0x17c [e:\git\pg\src\scripts\samples\odbcclientsample.c @ 163] 09 ODBCClientSample!main(int argc = 0n1, char ** argv = 0x00000000`00322d90)+0x12 [e:\git\pg\src\scripts\samples\odbcclientsample.c @ 219] --------------090300070601030706090806 Content-Type: text/plain; charset=UTF-8; x-mac-type="0"; x-mac-creator="0"; name="0001-Fix-crash-during-connect-using-SSPI-auth.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-Fix-crash-during-connect-using-SSPI-auth.patch" From 00882823d9e888701fb8d055f5cb8a3a84f36818 Mon Sep 17 00:00:00 2001 From: Nikhil R Deshpande Date: Mon, 23 Jun 2014 13:33:47 -0700 Subject: [PATCH] Fix crash during connect using SSPI auth This patch fixes a NULL pointer dereference occurring when connecting using SSPI authentication (without kerberos, a local Windows user trying to connect to postgres instance on same host). --- dlg_specific.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlg_specific.c b/dlg_specific.c index 8e051af..54525e3 100644 --- a/dlg_specific.c +++ b/dlg_specific.c @@ -1740,7 +1740,7 @@ char *extract_attribute_setting(const char *str, const char *attr, BOOL ref_comm */ char *extract_extra_attribute_setting(const pgNAME setting, const char *attr) { - const char *str = GET_NAME(setting); + const char *str = SAFE_NAME(setting); const char *cptr, *sptr = NULL; char *rptr; BOOL allowed_cmd = FALSE, in_quote = FALSE, in_comment = FALSE; -- 1.8.5.2 (Apple Git-48) --------------090300070601030706090806 Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-odbc --------------090300070601030706090806--