Re: Replace remaining StrNCpy() by strlcpy()

Поиск
Список
Период
Сортировка
От David Rowley
Тема Re: Replace remaining StrNCpy() by strlcpy()
Дата
Msg-id CAApHDvoRuiXpca=KLi9R5MVzp+516QSgyrJg4Dj-3PU69e_Bfw@mail.gmail.com
обсуждение исходный текст
Ответ на Replace remaining StrNCpy() by strlcpy()  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
Ответы Re: Replace remaining StrNCpy() by strlcpy()  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On Mon, 3 Aug 2020 at 18:59, Peter Eisentraut
<peter.eisentraut@2ndquadrant.com> 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 rid of some of these, but are some
of the changes not a bit questionable?

e.g:

@@ -4367,7 +4367,7 @@ pgstat_send_archiver(const char *xlog, bool failed)
  */
  pgstat_setheader(&msg.m_hdr, PGSTAT_MTYPE_ARCHIVER);
  msg.m_failed = failed;
- StrNCpy(msg.m_xlog, xlog, sizeof(msg.m_xlog));
+ strlcpy(msg.m_xlog, xlog, sizeof(msg.m_xlog));
  msg.m_timestamp = GetCurrentTimestamp();
  pgstat_send(&msg, sizeof(msg));

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?

David



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: Re: Confusing behavior of create table like
Следующее
От: Ashutosh Sharma
Дата:
Сообщение: Re: recovering from "found xmin ... from before relfrozenxid ..."