Re: Replace remaining StrNCpy() by strlcpy()

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Replace remaining StrNCpy() by strlcpy()
Дата
Msg-id 2267028.1596454733@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Replace remaining StrNCpy() by strlcpy()  (David Rowley <dgrowleyml@gmail.com>)
Ответы Re: Replace remaining StrNCpy() by strlcpy()  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
David Rowley <dgrowleyml@gmail.com> 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 collector?

StrNCpy doesn't zero-fill the destination today either (except for
the very last byte).  If you need that, you need to memset the
dest buffer ahead of time.

I didn't review the patch in complete detail, but the principle
seems sound to me, and strlcpy is surely more standard than StrNCpy.

            regards, tom lane



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

Предыдущее
От: ilmari@ilmari.org (Dagfinn Ilmari Mannsåker)
Дата:
Сообщение: Re: [PATCH] Add section headings to index types doc
Следующее
От: Amit Langote
Дата:
Сообщение: Re: [POC] Fast COPY FROM command for the table with foreign partitions