Re: Replace remaining StrNCpy() by strlcpy()

2020-08-10 Thread Peter Eisentraut
On 2020-08-08 18:09, Tom Lane wrote: Peter Eisentraut writes: I removed namecpy() altogether because you can just use struct assignment. Makes sense, and I notice it was unused anyway. v3 passes eyeball examination (I didn't bother running tests), with only one remaining nit: the proposed co

Re: Replace remaining StrNCpy() by strlcpy()

2020-08-08 Thread Tom Lane
Peter Eisentraut writes: > I removed namecpy() altogether because you can just use struct assignment. Makes sense, and I notice it was unused anyway. v3 passes eyeball examination (I didn't bother running tests), with only one remaining nit: the proposed commit message says They are equ

Re: Replace remaining StrNCpy() by strlcpy()

2020-08-07 Thread Peter Eisentraut
On 2020-08-05 17:49, Tom Lane wrote: However I do see one remaining nit to pick, in CreateInitDecodingContext: /* register output plugin name with slot */ SpinLockAcquire(&slot->mutex); - StrNCpy(NameStr(slot->data.plugin), plugin, NAMEDATALEN); + namestrcpy(&slot->data

Re: Replace remaining StrNCpy() by strlcpy()

2020-08-05 Thread David Rowley
On Tue, 4 Aug 2020 at 00:12, Tom Lane wrote: > > I wrote: > > David Rowley writes: > >> Will mean that we'll now no longer zero the full length of the m_xlog > >> field after the end of the string. Won't that mean we'll start writing > >> junk bytes to the stats collector? > > > StrNCpy doesn't z

Re: Replace remaining StrNCpy() by strlcpy()

2020-08-05 Thread Tom Lane
Peter Eisentraut writes: > 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(). I've looked through this patch, and I concur with your conclusion that noplace else is depe

Re: Replace remaining StrNCpy() by strlcpy()

2020-08-04 Thread Peter Eisentraut
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.

Re: Replace remaining StrNCpy() by strlcpy()

2020-08-03 Thread Tom Lane
Peter Eisentraut writes: > On 2020-08-03 14:12, Tom Lane wrote: >> In the specific case of the stats collector, if you don't want >> to be sending junk bytes then you'd better be memset'ing the >> whole message buffer not just this string field. So I'm not >> sure that the argument has any force

Re: Replace remaining StrNCpy() by strlcpy()

2020-08-03 Thread Peter Eisentraut
On 2020-08-03 14:12, Tom Lane wrote: I wrote: David Rowley writes: Will mean that we'll now no longer zero the full length of the m_xlog field after the end of the string. Won't that mean we'll start writing junk bytes to the stats collector? StrNCpy doesn't zero-fill the destination today

Re: Replace remaining StrNCpy() by strlcpy()

2020-08-03 Thread Tom Lane
I wrote: > David Rowley writes: >> Will mean that we'll now no longer zero the full length of the m_xlog >> field after the end of the string. Won't that mean we'll start writing >> junk bytes to the stats collector? > StrNCpy doesn't zero-fill the destination today either (except for > the very

Re: Replace remaining StrNCpy() by strlcpy()

2020-08-03 Thread Tom Lane
David Rowley writes: > - StrNCpy(msg.m_xlog, xlog, sizeof(msg.m_xlog)); > + strlcpy(msg.m_xlog, xlog, sizeof(msg.m_xlog)); > Will mean that we'll now no longer zero the full length of the m_xlog > field after the end of the string. Won't that mean we'll start writing > junk bytes to the stats col

Re: Replace remaining StrNCpy() by strlcpy()

2020-08-03 Thread David Rowley
On Mon, 3 Aug 2020 at 18:59, Peter Eisentraut wrote: > I propose to replace the remaining uses of StrNCpy() with strlcpy() and > remove the former. It's clear that strlcpy() has won the popularity > contest, and the presence of the former is just confusing now. It certainly would be good to get