odbc bug in convert.c - Mailing list pgsql-odbc

From Thomas Zehbe
Subject odbc bug in convert.c
Date
Msg-id 200407161250.51614.tz@ingenion.de
Whole thread Raw
Responses Re: odbc bug in convert.c
Re: odbc bug in convert.c
List pgsql-odbc
Hello!
I just debugged convert.c because it crashed with a segmentation violation.
The driver version I use is "psqlodbc-07.03.0200" wich i compiled from scratch
with the only option "--with-iodbc". The config.log from ./configure is
attached.
My client system is a SUSE 9.0 LINUX distribution with a "2.4.21-99-athlon"
kernel connected to a PostgreSQL 7.3.4 Server.
This is the code (starting at line 1041, with HAVE_LOCAL_H defined) which
crashed:
<snip>
            case SQL_C_FLOAT:
#ifdef HAVE_LOCALE_H
                strcpy(saved_locale, setlocale(LC_ALL, NULL));
                setlocale(LC_ALL, "C");
#endif /* HAVE_LOCALE_H */
                len = 4;
                if (bind_size > 0)
                    *((SFLOAT *) rgbValueBindRow) = (float) atof(neut_str);
                else
                    *((SFLOAT *) rgbValue + bind_row) = (float) atof(neut_str);
#ifdef HAVE_LOCALE_H
                setlocale(LC_ALL, saved_locale);
#endif /* HAVE_LOCALE_H */
                break;
</snip>
The "strcpy(saved_locale, setlocale(LC_ALL, NULL));" wites 326 bytes to the
"saved_locale" target, wich is only 256 bytes long (defined at line 387).
This results in overwriting the contents of "bind_size", "rgbValueBindRow"
and "rgbValue" which leads to the sigseg.
Defining
    char saved_locale[1024];
solved the problem.
BTW Many thanks for your work!
Best regards

Thomas Zehbe

INGENION GmbH
Luther Weg 50
31515 Wunstorf

Tel 05031-902042
Fax 05031-902049
www.ingenion.de

Attachment

pgsql-odbc by date:

Previous
From: surfunbear@yahoo.com (Larry)
Date:
Subject: ODBC questions
Next
From: Peter Eisentraut
Date:
Subject: Re: odbc bug in convert.c