Re: pnstrdup considered armed and dangerous

Поиск
Список
Период
Сортировка
От Geoff Winkless
Тема Re: pnstrdup considered armed and dangerous
Дата
Msg-id CAEzk6ffQGGykqNdR-fcGi9grj0=m6QXVV7CqM2i6N5XGZTHCAA@mail.gmail.com
обсуждение исходный текст
Ответ на pnstrdup considered armed and dangerous  (Andres Freund <andres@anarazel.de>)
Ответы Re: pnstrdup considered armed and dangerous  (Geoff Winkless <pgsqladmin@geoff.dj>)
Список pgsql-hackers
On 3 October 2016 at 22:55, Andres Freund <andres@anarazel.de> wrote:
> A colleage of me just wrote innocent looking code like
>         char *shardRelationName = pnstrdup(relationName, NAMEDATALEN);
> which is at the moment wrong if relationName isn't preallocated to
> NAMEDATALEN size.
[snip]
> isn't that a somewhat weird behaviour / implementation? Not really like
> strndup(), which one might believe to be analoguous...

Well I wouldn't say it's wrong, exactly. It might produce a segfault
if relationName[NAMEDATALEN] is outside readable memory for the
process, but otherwise it will behave as defined.

Geoff



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

Предыдущее
От: Masahiko Sawada
Дата:
Сообщение: Re: Transactions involving multiple postgres foreign servers
Следующее
От: Geoff Winkless
Дата:
Сообщение: Re: pnstrdup considered armed and dangerous