Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 31FDA1F6FE32 for ; Wed, 11 Jul 2012 18:41:43 -0300 (ADT) Received: from sd.tpf.co.jp ([210.161.239.34]) by makus.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1Sp4fG-000589-0x for pgsql-odbc@postgresql.org; Wed, 11 Jul 2012 21:41:43 +0000 Received: (qmail 24841 invoked by uid 512); 11 Jul 2012 21:41:27 -0000 X-Authentication: inoue was authenticated by sd.tpf.co.jp at 11 Jul 2012 21:41:27 -0000 Received: from unknown (HELO ?192.168.2.101?) (183.76.21.62) by sd.tpf.co.jp with SMTP; 11 Jul 2012 21:41:27 -0000 Message-ID: <4FFDF2FE.2080502@tpf.co.jp> Date: Thu, 12 Jul 2012 06:41:18 +0900 From: Hiroshi Inoue User-Agent: Mozilla/5.0 (Windows NT 6.0; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 MIME-Version: 1.0 To: tenger@iseries-guru.com CC: pgsql-odbc@postgresql.org, lionel@mamane.lu Subject: Re: segfault in SQLSpecialColumns when table name is null string References: <1341922972.25065.19.camel@cougar-natty> In-Reply-To: <1341922972.25065.19.camel@cougar-natty> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201207/3 X-Sequence-Number: 10897 Hi Terrence, (2012/07/10 21:22), Terrence Enger wrote: > Greetings, > > This message arises from LibreOffice bug report > "SIGSEGV: ODBC to PostgreSQL, renaming column in SELECT list" > , but I shall try > not to make you read that report. > > Working with PostgreSQL version 8.4.12-0ubuntu11.04 and with ODBC > driver versions 1:08.03.0200-1.2 (supplied with ubuntu-natty (11.04)) > and pgsqlodbc-09.01.0100 (built locally), I have managed to provoke a > segfault by calling SQLSpecialColumns with a null string for the table > name. This call is, of course, a strange thing to do, and I cannot > imagine any good result. Still, a segfault seems a disproportionate > punishment for doing something silly. > > The segfault happens in SQLSpecialColumns at odbcapi.c line 790, which reads > if (SQL_SUCCESS == ret && 0 == QR_get_num_total_tuples(SC_get_Result(stmt))) > The condition tries to dereference stmt->result, which is NULL. > > Along the way to this result, PGAPI_SpecialColumns at info.c lines > 2783 through 2786 detects the bad table name and does an early return. > But the return value SQL_SUCCESS seems wrong. Seems a real cause of the problem. I would fix it and commit the change to CVS soon. regards, Hiroshi Inoue