aboutsummaryrefslogtreecommitdiff
path: root/string/string.h
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2023-06-14 18:10:08 +0200
committerFlorian Weimer <fweimer@redhat.com>2023-06-14 18:10:08 +0200
commit454a20c8756c9c1d55419153255fc7692b3d2199 (patch)
treea65ad84288a247995183089f4400e4fd080ecc9d /string/string.h
parent7ba426a1115318fc11f4355f3161f35817a06ba4 (diff)
downloadglibc-454a20c8756c9c1d55419153255fc7692b3d2199.zip
glibc-454a20c8756c9c1d55419153255fc7692b3d2199.tar.gz
glibc-454a20c8756c9c1d55419153255fc7692b3d2199.tar.bz2
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>
Diffstat (limited to 'string/string.h')
-rw-r--r--string/string.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/string/string.h b/string/string.h
index 4927879..c0773d1 100644
--- a/string/string.h
+++ b/string/string.h
@@ -501,6 +501,19 @@ extern char *stpncpy (char *__restrict __dest,
__THROW __nonnull ((1, 2));
#endif
+#ifdef __USE_MISC
+/* Copy at most N - 1 characters from SRC to DEST. */
+extern size_t strlcpy (char *__restrict __dest,
+ const char *__restrict __src, size_t __n)
+ __THROW __nonnull ((1, 2)) __attr_access ((__write_only__, 1, 3));
+
+/* Append SRC to DEST, possibly with truncation to keep the total size
+ below N. */
+extern size_t strlcat (char *__restrict __dest,
+ const char *__restrict __src, size_t __n)
+ __THROW __nonnull ((1, 2)) __attr_access ((__read_write__, 1, 3));
+#endif
+
#ifdef __USE_GNU
/* Compare S1 and S2 as strings holding name & indices/version numbers. */
extern int strverscmp (const char *__s1, const char *__s2)