Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id D83FCC83CAD for ; Tue, 10 Jul 2012 09:23:18 -0300 (ADT) Received: from mailout.easydns.com ([64.68.200.141]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SoZTH-0005j0-7X for pgsql-odbc@postgresql.org; Tue, 10 Jul 2012 12:23:17 +0000 Received: from localhost (localhost [127.0.0.1]) by mailout.easydns.com (Postfix) with ESMTP id 9B9FAE0F0; Tue, 10 Jul 2012 08:22:59 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at mailout.easydns.com Received: from mailout.easydns.com ([127.0.0.1]) by localhost (mailout.easydns.vpn [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ycoBY5X+ht4J; Tue, 10 Jul 2012 08:22:58 -0400 (EDT) Received: from [192.168.0.103] (174-138-206-49.cpe.distributel.net [174.138.206.49]) by mailout.easydns.com (Postfix) with ESMTPA id DE235E0E6; Tue, 10 Jul 2012 08:22:57 -0400 (EDT) Subject: segfault in SQLSpecialColumns when table name is null string From: Terrence Enger Reply-To: tenger@iseries-guru.com To: pgsql-odbc@postgresql.org Cc: lionel@mamane.lu Content-Type: text/plain; charset="UTF-8" Date: Tue, 10 Jul 2012 08:22:52 -0400 Message-ID: <1341922972.25065.19.camel@cougar-natty> Mime-Version: 1.0 X-Mailer: Evolution 2.32.2 Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.6 (--) X-Archive-Number: 201207/1 X-Sequence-Number: 10895 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. When I used gdb to fudge the return value to SQL_ERROR, there was no segfault. Do you need more information? Can I do something else to help? Thank you, all for your attention. Terry. ( I tried earlier to send this message before my address was subscribed, and that earlier attempt is waiting for moderation. If this attempt gets through, I shall ask to moderator to cancel the first attempt. I apologize for the duplication or confusion. )