Re: function returning a row

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: function returning a row
Дата
Msg-id 20648.1107192211@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: function returning a row  (Kjetil Haaland <kjetil.haaland@student.uib.no>)
Ответы Re: function returning a row  (Kjetil Haaland <kjetil.haaland@student.uib.no>)
Список pgsql-novice
Kjetil Haaland <kjetil.haaland@student.uib.no> writes:
>     text *intext = PG_GETARG_TEXT_P(0);
>     text *smltext = PG_GETARG_TEXT_P(1);
>     in = (char*)palloc(VARSIZE(intext)-VARHDRSZ+1);
>     sml = (char*)palloc(VARSIZE(smltext)-VARHDRSZ+1);
>     snprintf (in, VARSIZE(intext) - VARHDRSZ + 1, VARDATA(intext));
>     snprintf (sml, VARSIZE(smltext) - VARHDRSZ + 1, VARDATA(smltext));

I'm not sure what you think the above snprintf's are going to do, but
it seems certain to be bad.  The "format string" you are passing is
neither null-terminated nor guaranteed to be free of %'s.

memcpy would be safer; and of course you need to explicitly append a
null byte afterwards.

            regards, tom lane

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

Предыдущее
От: Kjetil Haaland
Дата:
Сообщение: Re: function returning a row
Следующее
От: "Van Ingen, Lane"
Дата:
Сообщение: Date / Time Data Type