aboutsummaryrefslogtreecommitdiff
path: root/posix/bits/unistd.h
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2020-05-04 11:21:50 -0600
committerMartin Sebor <msebor@redhat.com>2020-05-04 11:21:50 -0600
commit06febd8c6705c816b2f32ee7aa1f4c0184b05248 (patch)
tree71586b8485abc1c6b220cb6aba340e76286b3087 /posix/bits/unistd.h
parent38c67888183db1b6ac21f2f9681b8a384987dfe8 (diff)
downloadglibc-06febd8c6705c816b2f32ee7aa1f4c0184b05248.zip
glibc-06febd8c6705c816b2f32ee7aa1f4c0184b05248.tar.gz
glibc-06febd8c6705c816b2f32ee7aa1f4c0184b05248.tar.bz2
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 <dj@redhat.com>
Diffstat (limited to 'posix/bits/unistd.h')
-rw-r--r--posix/bits/unistd.h58
1 files changed, 35 insertions, 23 deletions
diff --git a/posix/bits/unistd.h b/posix/bits/unistd.h
index b8a8211..725a83e 100644
--- a/posix/bits/unistd.h
+++ b/posix/bits/unistd.h
@@ -21,9 +21,11 @@
#endif
extern ssize_t __read_chk (int __fd, void *__buf, size_t __nbytes,
- size_t __buflen) __wur;
+ size_t __buflen)
+ __wur __attr_access ((__write_only__, 2, 3));
extern ssize_t __REDIRECT (__read_alias, (int __fd, void *__buf,
- size_t __nbytes), read) __wur;
+ size_t __nbytes), read)
+ __wur __attr_access ((__write_only__, 2, 3));
extern ssize_t __REDIRECT (__read_chk_warn,
(int __fd, void *__buf, size_t __nbytes,
size_t __buflen), __read_chk)
@@ -46,15 +48,19 @@ read (int __fd, void *__buf, size_t __nbytes)
#ifdef __USE_UNIX98
extern ssize_t __pread_chk (int __fd, void *__buf, size_t __nbytes,
- __off_t __offset, size_t __bufsize) __wur;
+ __off_t __offset, size_t __bufsize)
+ __wur __attr_access ((__write_only__, 2, 3));
extern ssize_t __pread64_chk (int __fd, void *__buf, size_t __nbytes,
- __off64_t __offset, size_t __bufsize) __wur;
+ __off64_t __offset, size_t __bufsize)
+ __wur __attr_access ((__write_only__, 2, 3));
extern ssize_t __REDIRECT (__pread_alias,
(int __fd, void *__buf, size_t __nbytes,
- __off_t __offset), pread) __wur;
+ __off_t __offset), pread)
+ __wur __attr_access ((__write_only__, 2, 3));
extern ssize_t __REDIRECT (__pread64_alias,
(int __fd, void *__buf, size_t __nbytes,
- __off64_t __offset), pread64) __wur;
+ __off64_t __offset), pread64)
+ __wur __attr_access ((__write_only__, 2, 3));
extern ssize_t __REDIRECT (__pread_chk_warn,
(int __fd, void *__buf, size_t __nbytes,
__off_t __offset, size_t __bufsize), __pread_chk)
@@ -123,11 +129,11 @@ pread64 (int __fd, void *__buf, size_t __nbytes, __off64_t __offset)
extern ssize_t __readlink_chk (const char *__restrict __path,
char *__restrict __buf, size_t __len,
size_t __buflen)
- __THROW __nonnull ((1, 2)) __wur;
+ __THROW __nonnull ((1, 2)) __wur __attr_access ((__write_only__, 2, 3));
extern ssize_t __REDIRECT_NTH (__readlink_alias,
(const char *__restrict __path,
char *__restrict __buf, size_t __len), readlink)
- __nonnull ((1, 2)) __wur;
+ __nonnull ((1, 2)) __wur __attr_access ((__write_only__, 2, 3));
extern ssize_t __REDIRECT_NTH (__readlink_chk_warn,
(const char *__restrict __path,
char *__restrict __buf, size_t __len,
@@ -155,12 +161,12 @@ __NTH (readlink (const char *__restrict __path, char *__restrict __buf,
extern ssize_t __readlinkat_chk (int __fd, const char *__restrict __path,
char *__restrict __buf, size_t __len,
size_t __buflen)
- __THROW __nonnull ((2, 3)) __wur;
+ __THROW __nonnull ((2, 3)) __wur __attr_access ((__write_only__, 3, 4));
extern ssize_t __REDIRECT_NTH (__readlinkat_alias,
(int __fd, const char *__restrict __path,
char *__restrict __buf, size_t __len),
readlinkat)
- __nonnull ((2, 3)) __wur;
+ __nonnull ((2, 3)) __wur __attr_access ((__write_only__, 3, 4));
extern ssize_t __REDIRECT_NTH (__readlinkat_chk_warn,
(int __fd, const char *__restrict __path,
char *__restrict __buf, size_t __len,
@@ -187,9 +193,10 @@ __NTH (readlinkat (int __fd, const char *__restrict __path,
#endif
extern char *__getcwd_chk (char *__buf, size_t __size, size_t __buflen)
- __THROW __wur;
+ __THROW __wur __attr_access ((__write_only__, 1, 2));
extern char *__REDIRECT_NTH (__getcwd_alias,
- (char *__buf, size_t __size), getcwd) __wur;
+ (char *__buf, size_t __size), getcwd)
+ __wur __attr_access ((__write_only__, 1, 2));
extern char *__REDIRECT_NTH (__getcwd_chk_warn,
(char *__buf, size_t __size, size_t __buflen),
__getcwd_chk)
@@ -212,7 +219,7 @@ __NTH (getcwd (char *__buf, size_t __size))
#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
extern char *__getwd_chk (char *__buf, size_t buflen)
- __THROW __nonnull ((1)) __wur;
+ __THROW __nonnull ((1)) __wur __attr_access ((__write_only__, 1, 2));
extern char *__REDIRECT_NTH (__getwd_warn, (char *__buf), getwd)
__nonnull ((1)) __wur __warnattr ("please use getcwd instead, as getwd "
"doesn't specify buffer size");
@@ -227,9 +234,11 @@ __NTH (getwd (char *__buf))
#endif
extern size_t __confstr_chk (int __name, char *__buf, size_t __len,
- size_t __buflen) __THROW;
+ size_t __buflen) __THROW
+ __attr_access ((__write_only__, 2, 3));
extern size_t __REDIRECT_NTH (__confstr_alias, (int __name, char *__buf,
- size_t __len), confstr);
+ size_t __len), confstr)
+ __attr_access ((__write_only__, 2, 3));
extern size_t __REDIRECT_NTH (__confstr_chk_warn,
(int __name, char *__buf, size_t __len,
size_t __buflen), __confstr_chk)
@@ -252,9 +261,9 @@ __NTH (confstr (int __name, char *__buf, size_t __len))
extern int __getgroups_chk (int __size, __gid_t __list[], size_t __listlen)
- __THROW __wur;
+ __THROW __wur __attr_access ((__write_only__, 2, 1));
extern int __REDIRECT_NTH (__getgroups_alias, (int __size, __gid_t __list[]),
- getgroups) __wur;
+ getgroups) __wur __attr_access ((__write_only__, 2, 1));
extern int __REDIRECT_NTH (__getgroups_chk_warn,
(int __size, __gid_t __list[], size_t __listlen),
__getgroups_chk)
@@ -277,7 +286,8 @@ __NTH (getgroups (int __size, __gid_t __list[]))
extern int __ttyname_r_chk (int __fd, char *__buf, size_t __buflen,
- size_t __nreal) __THROW __nonnull ((2));
+ size_t __nreal) __THROW __nonnull ((2))
+ __attr_access ((__write_only__, 2, 3));
extern int __REDIRECT_NTH (__ttyname_r_alias, (int __fd, char *__buf,
size_t __buflen), ttyname_r)
__nonnull ((2));
@@ -304,7 +314,7 @@ __NTH (ttyname_r (int __fd, char *__buf, size_t __buflen))
#ifdef __USE_POSIX199506
extern int __getlogin_r_chk (char *__buf, size_t __buflen, size_t __nreal)
- __nonnull ((1));
+ __nonnull ((1)) __attr_access ((__write_only__, 1, 2));
extern int __REDIRECT (__getlogin_r_alias, (char *__buf, size_t __buflen),
getlogin_r) __nonnull ((1));
extern int __REDIRECT (__getlogin_r_chk_warn,
@@ -331,9 +341,10 @@ getlogin_r (char *__buf, size_t __buflen)
#if defined __USE_MISC || defined __USE_UNIX98
extern int __gethostname_chk (char *__buf, size_t __buflen, size_t __nreal)
- __THROW __nonnull ((1));
+ __THROW __nonnull ((1)) __attr_access ((__write_only__, 1, 2));
extern int __REDIRECT_NTH (__gethostname_alias, (char *__buf, size_t __buflen),
- gethostname) __nonnull ((1));
+ gethostname)
+ __nonnull ((1)) __attr_access ((__write_only__, 1, 2));
extern int __REDIRECT_NTH (__gethostname_chk_warn,
(char *__buf, size_t __buflen, size_t __nreal),
__gethostname_chk)
@@ -358,10 +369,11 @@ __NTH (gethostname (char *__buf, size_t __buflen))
#if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_UNIX98)
extern int __getdomainname_chk (char *__buf, size_t __buflen, size_t __nreal)
- __THROW __nonnull ((1)) __wur;
+ __THROW __nonnull ((1)) __wur __attr_access ((__write_only__, 1, 2));
extern int __REDIRECT_NTH (__getdomainname_alias, (char *__buf,
size_t __buflen),
- getdomainname) __nonnull ((1)) __wur;
+ getdomainname) __nonnull ((1))
+ __wur __attr_access ((__write_only__, 1, 2));
extern int __REDIRECT_NTH (__getdomainname_chk_warn,
(char *__buf, size_t __buflen, size_t __nreal),
__getdomainname_chk)