Re: strncpy is not a safe version of strcpy

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Noah Misch <noah(at)leadboat(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Kevin Grittner <kgrittn(at)ymail(dot)com>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Tomas Vondra <tv(at)fuzzy(dot)cz>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: strncpy is not a safe version of strcpy
Date: 2014-08-15 22:38:39
Message-ID: CAApHDvp2ApXtiRgHvpUG2RaKkp0kEjzq2PAs7=NfFJv3CMGesg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Aug 14, 2014 at 4:13 PM, Noah Misch <noah(at)leadboat(dot)com> wrote:

> I share your (Kevin's) discomfort with our use of strlcpy(). I wouldn't
> mind
> someone replacing most strlcpy()/snprintf() calls with calls to wrappers
> that
> ereport(ERROR) on truncation. Though as reliability problems go, this one
> has
> been minor.
>
>
Or maybe it would be better to just remove the restriction and just palloc
something of the correct size?
Although, that sounds like a much larger patch. I'd vote that the strlcpy
should be used in the meantime.

Regards

David Rowley

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2014-08-15 23:19:00 Re: jsonb format is pessimal for toast compression
Previous Message Josh Berkus 2014-08-15 22:18:30 Re: [Bad Attachment] Re: jsonb format is pessimal for toast compression