From 06febd8c6705c816b2f32ee7aa1f4c0184b05248 Mon Sep 17 00:00:00 2001 From: Martin Sebor Date: Mon, 4 May 2020 11:21:50 -0600 Subject: improve out-of-bounds checking with GCC 10 attribute access [BZ #25219] Adds the access attribute newly introduced in GCC 10 to the subset of function declarations that are already covered by _FORTIFY_SOURCE and that don't have corresponding GCC built-in equivalents. Reviewed-by: DJ Delorie --- string/bits/string_fortified.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'string/bits') diff --git a/string/bits/string_fortified.h b/string/bits/string_fortified.h index e4d07cb50c..309d0f39b2 100644 --- a/string/bits/string_fortified.h +++ b/string/bits/string_fortified.h @@ -75,7 +75,7 @@ __NTH (memset (void *__dest, int __ch, size_t __len)) # include void __explicit_bzero_chk (void *__dest, size_t __len, size_t __destlen) - __THROW __nonnull ((1)); + __THROW __nonnull ((1)) __attr_access ((__write_only__, 1, 2)); __fortify_function void __NTH (explicit_bzero (void *__dest, size_t __len)) @@ -108,7 +108,8 @@ __NTH (strncpy (char *__restrict __dest, const char *__restrict __src, /* XXX We have no corresponding builtin yet. */ extern char *__stpncpy_chk (char *__dest, const char *__src, size_t __n, - size_t __destlen) __THROW; + size_t __destlen) __THROW + __attr_access ((__write_only__, 1, 3)) __attr_access ((__read_only__, 2)); extern char *__REDIRECT_NTH (__stpncpy_alias, (char *__dest, const char *__src, size_t __n), stpncpy); -- cgit v1.2.3