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
|
| Список | 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 по дате отправления: