odbc bug in convert.c
odbc bug in convert.c
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: 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; 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
Re: odbc bug in convert.c
От:
Peter Eisentraut <peter_e@gmx.net>
Дата:
Thomas Zehbe wrote: > 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). How is it possible for a locale name to be 326 bytes long? What is the actual value that is copied? -- Peter Eisentraut http://developer.postgresql.org/~petere/
Re: odbc bug in convert.c
От:
Peter Eisentraut <peter_e@gmx.net>
Дата:
Thomas Zehbe wrote: > This is the code (starting at line 1041, with HAVE_LOCAL_H defined) > which crashed: > > case SQL_C_FLOAT: > #ifdef HAVE_LOCALE_H > strcpy(saved_locale, setlocale(LC_ALL, NULL)); > setlocale(LC_ALL, "C"); > #endif /* HAVE_LOCALE_H */ I've changed this to do dynamic allocation. Please try again with CVS tip. -- Peter Eisentraut http://developer.postgresql.org/~petere/