ECPG segfault

Поиск
Список
Период
Сортировка
От Jürgen Cappel
Тема ECPG segfault
Дата
Msg-id JEEKIPNAKJNCFLMOBKHGKEHKDCAA.email@juergen-cappel.de
обсуждение исходный текст
Ответы Re: ECPG segfault  (Michael Meskes <meskes@postgresql.org>)
Re: ECPG segfault  (Bruce Momjian <pgman@candle.pha.pa.us>)
Список pgsql-interfaces
The code in ecpg/preproc/type.c has a problem when allocating
memory. I'm referring to the function ECPGdump_a_simple() where
one of the first actions is allocating memory and assigning it
to variable "offset". The amount of memory requested depends on
the size of the variable's name and the length of a fixed string.
The function has a parameter called "varcharsize" (array size string)
which is later used in the "case ECPGt_char:" where it is included
in an sprintf() to fill the allocated memory area. This leads to
a subsequent segmentation fault if "varcharsize" is not a simple
integer but maybe a cpp macro of some length, say, 20 bytes. At
least it *can* lead to a segfault, because you never know how and
when memory corruption strikes back on you ...

Using my example, things work well when allocating a few bytes more,
but i would suggest adding a strlen(varcharsize) instead of 1 byte
for allocation of "offset".

Comments are welcome !  Best regards, Jürgen Cappel

Oh, and btw thanks to valgrind for pointing me to that place :-)



В списке pgsql-interfaces по дате отправления:

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: Re: Portable interfaces ...
Следующее
От: "B Feilmeier"
Дата:
Сообщение: PostgreSQL-Perl Interface installation