Bug 178 - Please add strlcpy and strlcat (attached)
Summary: Please add strlcpy and strlcat (attached)
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: string (show other bugs)
Version: unspecified
: P2 enhancement
Target Milestone: 2.38
Assignee: Florian Weimer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-05-24 20:19 UTC by rmh
Modified: 2023-06-14 16:43 UTC (History)
7 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments
strlcat implementation (1.20 KB, text/plain)
2004-05-24 20:21 UTC, rmh
Details
strlcpy implementation (1.16 KB, text/plain)
2004-05-24 20:22 UTC, rmh
Details

Note You need to log in before you can comment on or make changes to this bug.
Description rmh 2004-05-24 20:19:29 UTC
I'm attaching the strlcpy.c and strlcat.c files, not the patch to integrate them
as I don't know the glibc-makefile magic for this.
Comment 1 rmh 2004-05-24 20:21:47 UTC
Created attachment 91 [details]
strlcat implementation

This is extracted from FreeBSD CVS. I assume the license is acceptable since it
is GPL/LGPL compatible.
Comment 2 rmh 2004-05-24 20:22:28 UTC
Created attachment 92 [details]
strlcpy implementation

This is extracted from FreeBSD CVS. I assume the license is acceptable since it
is GPL/LGPL compatible.
Comment 3 Roland McGrath 2004-05-25 18:50:49 UTC
This report contains no claims of justification for adding these interfaces.
These have been suggested before and discussed on the mailing list.
We don't consider them worthwhile.  Please locate that old discussion for details.
Comment 4 zeratul2@wanadoo.es 2004-05-25 19:51:21 UTC
Subject: Re:  Please add strlcpy and strlcat (attached)

On Tue, May 25, 2004 at 06:50:51PM -0000, roland at gnu dot org wrote:
> 
> ------- Additional Comments From roland at gnu dot org  2004-05-25 18:50 -------
> This report contains no claims of justification for adding these interfaces.
> These have been suggested before and discussed on the mailing list.
> We don't consider them worthwhile.  Please locate that old discussion for details.

Oh, I see this was discussed already. Sorry for the oversight.

Comment 5 Florian Weimer 2014-09-08 11:53:18 UTC
I'm working on a patch to add this function.
Comment 6 Sam James 2022-12-23 06:55:49 UTC
strlcpy and strlcat will be in the next POSIX edition (https://www.austingroupbugs.net/view.php?id=986).

Florian sent a patch to libc-alpha in June: https://patchwork.sourceware.org/project/glibc/patch/87fsjp7rqz.fsf@oldenburg.str.redhat.com/.
Comment 7 Florian Weimer 2023-04-05 11:25:46 UTC
New patches posted:

[PATCH 0/2] strlcpy/strlcat/wcslcpy/wcscat implementation
<https://sourceware.org/pipermail/libc-alpha/2023-April/146967.html>
Comment 8 Florian Weimer 2023-06-14 16:43:27 UTC
Fixed for 2.38 via:

commit 454a20c8756c9c1d55419153255fc7692b3d2199
Author: Florian Weimer <fweimer@redhat.com>
Date:   Wed Jun 14 18:10:08 2023 +0200

    Implement strlcpy and strlcat [BZ #178]
    
    These functions are about to be added to POSIX, under Austin Group
    issue 986.
    
    The fortified strlcat implementation does not raise SIGABRT if the
    destination buffer does not contain a null terminator, it just
    inherits the non-failing regular strlcat behavior.
    
    Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>