Re: [PATCH 15/67] convert trivial sprintf / strcpy calls to xsnprintf
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 16, 2015, 01:34 UTC
- Message-ID
- <xmqqd1xjtaej.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <55F8643D.6040800@ramsayjones.plus.com>
Ramsay Jones <ramsay@ramsayjones.plus.com> writes:
Show 6 quoted lines
> How about using strlcpy() instead? Thus: > > - strcpy(header.name, "pax_global_header"); > + strlcpy(header.name, "pax_global_header", sizeof(header.name)); > > Ditto for other similar (strcpy->xsnprintf) hunks below.
Please do not advocate use of strlcpy(), which substitutes overwriting beyond the end of the buffer (which is a bug) with a silent truncation (which is almost always another bug, unless in a very narrow case of producing a non-essential string result where loss of information does not matter).