From: | Geoff Winkless <pgsqladmin(at)geoff(dot)dj> |
---|---|
To: | Andres Freund <andres(at)anarazel(dot)de> |
Cc: | Pg Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: pnstrdup considered armed and dangerous |
Date: | 2016-10-04 13:12:18 |
Message-ID: | CAEzk6ffQGGykqNdR-fcGi9grj0=m6QXVV7CqM2i6N5XGZTHCAA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 3 October 2016 at 22:55, Andres Freund <andres(at)anarazel(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Geoff Winkless | 2016-10-04 13:17:17 | Re: pnstrdup considered armed and dangerous |
Previous Message | Masahiko Sawada | 2016-10-04 13:08:28 | Re: Transactions involving multiple postgres foreign servers |