From: guenther Date: Sat, 3 Aug 2024 20:13:23 +0000 (+0000) Subject: The improbable occurred: strlcpy(3) and strlcat(3) are in POSIX-2024. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=4af81b37ced6d7e969e2e8eba245210dae4b89d1;p=openbsd The improbable occurred: strlcpy(3) and strlcat(3) are in POSIX-2024. memmem(3) was also added. Update #include visibility and manpages and add restrict qualifiers. "never thought I'd see this day" millert@ --- diff --git a/include/string.h b/include/string.h index f1d0cbc81fd..f3870948c2b 100644 --- a/include/string.h +++ b/include/string.h @@ -1,4 +1,4 @@ -/* $OpenBSD: string.h,v 1.33 2024/06/23 07:08:26 otto Exp $ */ +/* $OpenBSD: string.h,v 1.34 2024/08/03 20:13:23 guenther Exp $ */ /* $NetBSD: string.h,v 1.6 1994/10/26 00:56:30 cgd Exp $ */ /*- @@ -118,16 +118,19 @@ size_t strxfrm_l(char *__restrict, const char *__restrict, size_t, locale_t) __attribute__ ((__bounded__(__string__,1,3))); #endif +#if __POSIX_VISIBLE >= 202405 || __BSD_VISIBLE +void *memmem(const void *, size_t, const void *, size_t); +size_t strlcat(char *__restrict, const char *__restrict, size_t) + __attribute__ ((__bounded__(__string__,1,3))); +size_t strlcpy(char *__restrict, const char *__restrict, size_t) + __attribute__ ((__bounded__(__string__,1,3))); +#endif + #if __BSD_VISIBLE void explicit_bzero(void *, size_t) __attribute__ ((__bounded__(__buffer__,1,2))); -void *memmem(const void *, size_t, const void *, size_t); void *memrchr(const void *, int, size_t); char *strcasestr(const char *, const char *); -size_t strlcat(char *, const char *, size_t) - __attribute__ ((__bounded__(__string__,1,3))); -size_t strlcpy(char *, const char *, size_t) - __attribute__ ((__bounded__(__string__,1,3))); void strmode(__mode_t, char *); char *strsep(char **, const char *); int timingsafe_bcmp(const void *, const void *, size_t); diff --git a/lib/libc/string/memmem.3 b/lib/libc/string/memmem.3 index 3f178590836..de62d738dee 100644 --- a/lib/libc/string/memmem.3 +++ b/lib/libc/string/memmem.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: memmem.3,v 1.3 2020/04/16 12:40:41 claudio Exp $ +.\" $OpenBSD: memmem.3,v 1.4 2024/08/03 20:13:23 guenther Exp $ .\" .\" Copyright (c) 2005 Pascal Gloor .\" @@ -26,7 +26,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd $Mdocdate: April 16 2020 $ +.Dd $Mdocdate: August 3 2024 $ .Dt MEMMEM 3 .Os .Sh NAME @@ -66,8 +66,10 @@ is returned. .Xr strchr 3 , .Xr strstr 3 .Sh STANDARDS +The .Fn memmem -is a GNU extension. +function conforms to +.St -p1003.1-2024 . .Sh HISTORY The .Fn memmem diff --git a/lib/libc/string/strlcpy.3 b/lib/libc/string/strlcpy.3 index a14145e199f..46072898838 100644 --- a/lib/libc/string/strlcpy.3 +++ b/lib/libc/string/strlcpy.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: strlcpy.3,v 1.27 2019/01/25 00:19:25 millert Exp $ +.\" $OpenBSD: strlcpy.3,v 1.28 2024/08/03 20:13:23 guenther Exp $ .\" .\" Copyright (c) 1998, 2000 Todd C. Miller .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: January 25 2019 $ +.Dd $Mdocdate: August 3 2024 $ .Dt STRLCPY 3 .Os .Sh NAME @@ -24,9 +24,9 @@ .Sh SYNOPSIS .In string.h .Ft size_t -.Fn strlcpy "char *dst" "const char *src" "size_t dstsize" +.Fn strlcpy "char * restrict dst" "const char * restrict src" "size_t dstsize" .Ft size_t -.Fn strlcat "char *dst" "const char *src" "size_t dstsize" +.Fn strlcat "char * restrict dst" "const char * restrict src" "size_t dstsize" .Sh DESCRIPTION The .Fn strlcpy @@ -174,6 +174,13 @@ As a matter of fact, the first version of this manual page got it wrong. .Xr strncat 3 , .Xr strncpy 3 , .Xr wcslcpy 3 +.Sh STANDARDS +The +.Fn strlcat +and +.Fn strlcpy +functions conform to +.St -p1003.1-2024 . .Sh HISTORY .Fn strlcpy and