master
  1/* Checking routines for unistd functions. Declaration only.
  2   Copyright (C) 2023-2025 Free Software Foundation, Inc.
  3   This file is part of the GNU C Library.
  4
  5   The GNU C Library is free software; you can redistribute it and/or
  6   modify it under the terms of the GNU Lesser General Public
  7   License as published by the Free Software Foundation; either
  8   version 2.1 of the License, or (at your option) any later version.
  9
 10   The GNU C Library is distributed in the hope that it will be useful,
 11   but WITHOUT ANY WARRANTY; without even the implied warranty of
 12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 13   Lesser General Public License for more details.
 14
 15   You should have received a copy of the GNU Lesser General Public
 16   License along with the GNU C Library; if not, see
 17   <https://www.gnu.org/licenses/>.  */
 18
 19#ifndef _BITS_UNISTD_DECL_H
 20#define _BITS_UNISTD_DECL_H 1
 21
 22#ifndef _UNISTD_H
 23# error "Never include <bits/unistd-decl.h> directly; use <unistd.h> instead."
 24#endif
 25
 26extern ssize_t __read_chk (int __fd, void *__buf, size_t __nbytes,
 27			   size_t __buflen)
 28     __wur __attr_access ((__write_only__, 2, 3));
 29extern ssize_t __REDIRECT_FORTIFY (__read_alias, (int __fd, void *__buf,
 30						  size_t __nbytes), read)
 31     __wur __attr_access ((__write_only__, 2, 3));
 32extern ssize_t __REDIRECT (__read_chk_warn,
 33			   (int __fd, void *__buf, size_t __nbytes,
 34			    size_t __buflen), __read_chk)
 35     __wur __warnattr ("read called with bigger length than size of "
 36		       "the destination buffer");
 37
 38#if defined __USE_UNIX98 || defined __USE_XOPEN2K8
 39extern ssize_t __pread_chk (int __fd, void *__buf, size_t __nbytes,
 40			    __off_t __offset, size_t __bufsize)
 41     __wur __attr_access ((__write_only__, 2, 3));
 42extern ssize_t __pread64_chk (int __fd, void *__buf, size_t __nbytes,
 43			      __off64_t __offset, size_t __bufsize)
 44     __wur __attr_access ((__write_only__, 2, 3));
 45extern ssize_t __REDIRECT (__pread_alias,
 46			   (int __fd, void *__buf, size_t __nbytes,
 47			    __off_t __offset), pread)
 48     __wur __attr_access ((__write_only__, 2, 3));
 49extern ssize_t __REDIRECT (__pread64_alias,
 50			   (int __fd, void *__buf, size_t __nbytes,
 51			    __off64_t __offset), pread64)
 52     __wur __attr_access ((__write_only__, 2, 3));
 53extern ssize_t __REDIRECT (__pread_chk_warn,
 54			   (int __fd, void *__buf, size_t __nbytes,
 55			    __off_t __offset, size_t __bufsize), __pread_chk)
 56     __wur __warnattr ("pread called with bigger length than size of "
 57		       "the destination buffer");
 58extern ssize_t __REDIRECT (__pread64_chk_warn,
 59			   (int __fd, void *__buf, size_t __nbytes,
 60			    __off64_t __offset, size_t __bufsize),
 61			    __pread64_chk)
 62     __wur __warnattr ("pread64 called with bigger length than size of "
 63		       "the destination buffer");
 64#endif
 65
 66#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K
 67extern ssize_t __readlink_chk (const char *__restrict __path,
 68			       char *__restrict __buf, size_t __len,
 69			       size_t __buflen)
 70     __THROW __nonnull ((1, 2)) __wur __attr_access ((__write_only__, 2, 3));
 71extern ssize_t __REDIRECT_NTH (__readlink_alias,
 72			       (const char *__restrict __path,
 73				char *__restrict __buf, size_t __len), readlink)
 74     __nonnull ((1, 2)) __wur __attr_access ((__write_only__, 2, 3));
 75extern ssize_t __REDIRECT_NTH (__readlink_chk_warn,
 76			       (const char *__restrict __path,
 77				char *__restrict __buf, size_t __len,
 78				size_t __buflen), __readlink_chk)
 79     __nonnull ((1, 2)) __wur __warnattr ("readlink called with bigger length "
 80					  "than size of destination buffer");
 81#endif
 82
 83#ifdef __USE_ATFILE
 84extern ssize_t __readlinkat_chk (int __fd, const char *__restrict __path,
 85				 char *__restrict __buf, size_t __len,
 86				 size_t __buflen)
 87     __THROW __nonnull ((2, 3)) __wur __attr_access ((__write_only__, 3, 4));
 88extern ssize_t __REDIRECT_NTH (__readlinkat_alias,
 89			       (int __fd, const char *__restrict __path,
 90				char *__restrict __buf, size_t __len),
 91			       readlinkat)
 92     __nonnull ((2, 3)) __wur __attr_access ((__write_only__, 3, 4));
 93extern ssize_t __REDIRECT_NTH (__readlinkat_chk_warn,
 94			       (int __fd, const char *__restrict __path,
 95				char *__restrict __buf, size_t __len,
 96				size_t __buflen), __readlinkat_chk)
 97     __nonnull ((2, 3)) __wur __warnattr ("readlinkat called with bigger "
 98					  "length than size of destination "
 99					  "buffer");
100#endif
101
102extern char *__getcwd_chk (char *__buf, size_t __size, size_t __buflen)
103     __THROW __wur;
104extern char *__REDIRECT_NTH (__getcwd_alias,
105			     (char *__buf, size_t __size), getcwd) __wur;
106extern char *__REDIRECT_NTH (__getcwd_chk_warn,
107			     (char *__buf, size_t __size, size_t __buflen),
108			     __getcwd_chk)
109     __wur __warnattr ("getcwd caller with bigger length than size of "
110		       "destination buffer");
111
112#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
113extern char *__getwd_chk (char *__buf, size_t buflen)
114     __THROW __nonnull ((1)) __wur __attr_access ((__write_only__, 1, 2));
115extern char *__REDIRECT_NTH (__getwd_warn, (char *__buf), getwd)
116     __nonnull ((1)) __wur __warnattr ("please use getcwd instead, as getwd "
117				       "doesn't specify buffer size");
118#endif
119
120extern size_t __confstr_chk (int __name, char *__buf, size_t __len,
121			     size_t __buflen) __THROW
122     __attr_access ((__write_only__, 2, 3));
123extern size_t __REDIRECT_NTH (__confstr_alias, (int __name, char *__buf,
124						size_t __len), confstr)
125     __attr_access ((__write_only__, 2, 3));
126extern size_t __REDIRECT_NTH (__confstr_chk_warn,
127			      (int __name, char *__buf, size_t __len,
128			       size_t __buflen), __confstr_chk)
129     __warnattr ("confstr called with bigger length than size of destination "
130		 "buffer");
131
132
133extern int __getgroups_chk (int __size, __gid_t __list[], size_t __listlen)
134     __THROW __wur __attr_access ((__write_only__, 2, 1));
135extern int __REDIRECT_NTH (__getgroups_alias, (int __size, __gid_t __list[]),
136			   getgroups) __wur __attr_access ((__write_only__, 2, 1));
137extern int __REDIRECT_NTH (__getgroups_chk_warn,
138			   (int __size, __gid_t __list[], size_t __listlen),
139			   __getgroups_chk)
140     __wur __warnattr ("getgroups called with bigger group count than what "
141		       "can fit into destination buffer");
142
143
144extern int __ttyname_r_chk (int __fd, char *__buf, size_t __buflen,
145			    size_t __nreal) __THROW __nonnull ((2))
146     __attr_access ((__write_only__, 2, 3));
147extern int __REDIRECT_NTH (__ttyname_r_alias, (int __fd, char *__buf,
148					       size_t __buflen), ttyname_r)
149     __nonnull ((2));
150extern int __REDIRECT_NTH (__ttyname_r_chk_warn,
151			   (int __fd, char *__buf, size_t __buflen,
152			    size_t __nreal), __ttyname_r_chk)
153     __nonnull ((2)) __warnattr ("ttyname_r called with bigger buflen than "
154				 "size of destination buffer");
155
156
157#ifdef __USE_POSIX199506
158extern int __getlogin_r_chk (char *__buf, size_t __buflen, size_t __nreal)
159     __nonnull ((1)) __attr_access ((__write_only__, 1, 2));
160extern int __REDIRECT_FORTIFY (__getlogin_r_alias, (char *__buf, size_t __buflen),
161		       getlogin_r) __nonnull ((1));
162extern int __REDIRECT (__getlogin_r_chk_warn,
163		       (char *__buf, size_t __buflen, size_t __nreal),
164		       __getlogin_r_chk)
165     __nonnull ((1)) __warnattr ("getlogin_r called with bigger buflen than "
166				 "size of destination buffer");
167#endif
168
169
170#if defined __USE_MISC || defined __USE_UNIX98
171extern int __gethostname_chk (char *__buf, size_t __buflen, size_t __nreal)
172     __THROW __nonnull ((1)) __attr_access ((__write_only__, 1, 2));
173extern int __REDIRECT_NTH (__gethostname_alias, (char *__buf, size_t __buflen),
174			   gethostname)
175     __nonnull ((1)) __attr_access ((__write_only__, 1, 2));
176extern int __REDIRECT_NTH (__gethostname_chk_warn,
177			   (char *__buf, size_t __buflen, size_t __nreal),
178			   __gethostname_chk)
179     __nonnull ((1)) __warnattr ("gethostname called with bigger buflen than "
180				 "size of destination buffer");
181#endif
182
183
184#if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_UNIX98)
185extern int __getdomainname_chk (char *__buf, size_t __buflen, size_t __nreal)
186     __THROW __nonnull ((1)) __wur __attr_access ((__write_only__, 1, 2));
187extern int __REDIRECT_FORTIFY_NTH (__getdomainname_alias, (char *__buf,
188						   size_t __buflen),
189			   getdomainname) __nonnull ((1))
190     __wur __attr_access ((__write_only__, 1, 2));
191extern int __REDIRECT_NTH (__getdomainname_chk_warn,
192			   (char *__buf, size_t __buflen, size_t __nreal),
193			   __getdomainname_chk)
194     __nonnull ((1)) __wur __warnattr ("getdomainname called with bigger "
195				       "buflen than size of destination "
196				       "buffer");
197#endif
198#endif /* bits/unistd-decl.h.  */