[PATCH v2] Implement strlcpy [BZ #178]
Florian Weimer
fweimer@redhat.com
Wed Sep 17 13:08:00 GMT 2014
On 09/15/2014 03:47 PM, Florian Weimer wrote:
> This patch adds an implementation of strlcpy.
>
> I think it shows that we can do much better than custom implementations
> in libbsd and random applications:
>
> * This version is based on optimized strnlen and memcpy implementation.
It's now strlen, as required.
>
> * It has fortify support.
>
> * In fortify mode, there a link-time warnings for common misuses.
> (The location of the warning could be improved,
> but this is a GCC issue.)
>
> If this is patch is accepted, I will work on an implementation of
> strlcat along similar lines.
This version fixes the return value (oops) and adjusts the documentation
to avoid the phrase âmore usefulâ.
I misremembered what the GNU coding standards say about dynamically
sized buffers. As far as I can tell, they recommend it not in general,
but only as a way to avoid unintentional copyright infringement. That's
why I didn't add a reference to the coding standards.
--
Florian Weimer / Red Hat Product Security
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Implement-strlcpy-BZ-178.patch
Type: text/x-patch
Size: 27602 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20140917/b5e17166/attachment.bin>
More information about the Libc-alpha
mailing list