Re: Replace remaining StrNCpy() by strlcpy() - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: Replace remaining StrNCpy() by strlcpy()
Date
Msg-id e7da7abc-3b55-3979-726c-72f91a3af0ce@2ndquadrant.com
Whole thread Raw
In response to Re: Replace remaining StrNCpy() by strlcpy()  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Replace remaining StrNCpy() by strlcpy()
List pgsql-hackers
On 2020-08-03 19:39, Tom Lane wrote:
>> That's easy to fix, but it's perhaps wondering briefly why it needs to
>> be zero-padded.  hashname() doesn't care, heap_form_tuple() doesn't
>> care.  Does anything care?
> 
> We do have an expectation that there are no undefined bytes in values to
> be stored on-disk.  There's even some code in coerce_type() that will
> complain about this:

Okay, here is a new patch with improved implementations of namecpy() and 
namestrcpy().  I didn't see any other places that relied on the 
zero-filling behavior of strncpy().

>> While we're here, shouldn't namestrcpy() do some pg_mbcliplen() stuff
>> like namein()?
> 
> Excellent point --- probably so, unless the callers are all truncating
> in advance, which I doubt.

I will look into that separately.

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachment

pgsql-hackers by date:

Previous
From: Stephen Frost
Date:
Subject: Re: Reduce/eliminate the impact of FPW
Next
From: Peter Eisentraut
Date:
Subject: Re: Since '2001-09-09 01:46:40'::timestamp microseconds are lost when extracting epoch