From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | David Rowley <dgrowleyml(at)gmail(dot)com> |
Cc: | Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Replace remaining StrNCpy() by strlcpy() |
Date: | 2020-08-03 11:38:53 |
Message-ID: | 2267028.1596454733@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
David Rowley <dgrowleyml(at)gmail(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Amit Langote | 2020-08-03 11:38:57 | Re: [POC] Fast COPY FROM command for the table with foreign partitions |
Previous Message | Dagfinn Ilmari Mannsåker | 2020-08-03 11:32:17 | Re: [PATCH] Add section headings to index types doc |