Re: strncpy is not a safe version of strcpy - Mailing list pgsql-hackers

From Stephen Frost
Subject Re: strncpy is not a safe version of strcpy
Date
Msg-id 20131115154809.GD17272@tamriel.snowman.net
Whole thread Raw
In response to Re: strncpy is not a safe version of strcpy  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
* Tom Lane (tgl@sss.pgh.pa.us) wrote:
> Andres Freund <andres@2ndquadrant.com> writes:
> > I didn't argue against s/strncpy/strlcpy/. That's clearly a sensible
> > fix.
> > I am arguing about introducing additional code and error messages about
> > it, that need to be translated. And starting doing so in isolationtester
> > of all places.
>
> I agree with Andres on this.  Commit
> 7cb964acb794078ef033cbf2e3a0e7670c8992a9 is the very definition of
> overkill, and I don't want to see us starting to plaster the source
> code with things like this.  Converting strncpy to strlcpy seems
> appropriate --- and sufficient.

Personally, I'd like to see better handling like this- but done in a way
which minimizes impact to code and translators.  A function like
namecpy() (which I agree with Kevin about- curious that it's not used..)
which handled the check, errmsg and exit seems reasonable to me, for the
"userland" binaries (and perhaps the postmaster when doing command-line
checking of, eg, -D) that need it.

Still, I'm not offering to go do it, so take my feelings on it with that
in mind. :)
Thanks,
    Stephen

pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: strncpy is not a safe version of strcpy
Next
From: Tom Lane
Date:
Subject: Re: SSL renegotiation