segfault in SQLSpecialColumns when table name is null string

From: Terrence Enger <tenger(at)iseries-guru(dot)com>
To: pgsql-odbc(at)postgresql(dot)org
Cc: lionel(at)mamane(dot)lu
Subject: segfault in SQLSpecialColumns when table name is null string
Date: 2012-07-10 12:22:52
Message-ID: 1341922972.25065.19.camel@cougar-natty
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-odbc

Greetings,

This message arises from LibreOffice bug report
"SIGSEGV: ODBC to PostgreSQL, renaming column in SELECT list"
<https://bugs.freedesktop.org/show_bug.cgi?id=50849>, 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. )

Responses

Browse pgsql-odbc by date

  From Date Subject
Next Message Lionel Elie Mamane 2012-07-10 14:27:07 Re: segfault in SQLSpecialColumns when table name is null string
Previous Message Maziar Navahan 2012-06-22 12:17:38 Re: can not configure in centos 6 x64