1be04fec4SKyle Evans /* $NetBSD: unistd.h,v 1.7 2015/06/25 18:41:03 joerg Exp $ */
2be04fec4SKyle Evans
3be04fec4SKyle Evans /*-
4be04fec4SKyle Evans *
5be04fec4SKyle Evans * SPDX-License-Identifier: BSD-2-Clause
6be04fec4SKyle Evans *
7be04fec4SKyle Evans * Copyright (c) 2006 The NetBSD Foundation, Inc.
8be04fec4SKyle Evans * All rights reserved.
9be04fec4SKyle Evans *
10be04fec4SKyle Evans * This code is derived from software contributed to The NetBSD Foundation
11be04fec4SKyle Evans * by Christos Zoulas.
12be04fec4SKyle Evans *
13be04fec4SKyle Evans * Redistribution and use in source and binary forms, with or without
14be04fec4SKyle Evans * modification, are permitted provided that the following conditions
15be04fec4SKyle Evans * are met:
16be04fec4SKyle Evans * 1. Redistributions of source code must retain the above copyright
17be04fec4SKyle Evans * notice, this list of conditions and the following disclaimer.
18be04fec4SKyle Evans * 2. Redistributions in binary form must reproduce the above copyright
19be04fec4SKyle Evans * notice, this list of conditions and the following disclaimer in the
20be04fec4SKyle Evans * documentation and/or other materials provided with the distribution.
21be04fec4SKyle Evans *
22be04fec4SKyle Evans * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
23be04fec4SKyle Evans * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
24be04fec4SKyle Evans * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25be04fec4SKyle Evans * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
26be04fec4SKyle Evans * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27be04fec4SKyle Evans * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28be04fec4SKyle Evans * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29be04fec4SKyle Evans * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30be04fec4SKyle Evans * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31be04fec4SKyle Evans * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32be04fec4SKyle Evans * POSSIBILITY OF SUCH DAMAGE.
33be04fec4SKyle Evans */
34be04fec4SKyle Evans #ifndef _SSP_UNISTD_H_
35be04fec4SKyle Evans #define _SSP_UNISTD_H_
36be04fec4SKyle Evans
37be04fec4SKyle Evans #include <ssp/ssp.h>
38be04fec4SKyle Evans
39be04fec4SKyle Evans #if __SSP_FORTIFY_LEVEL > 0
40be04fec4SKyle Evans __BEGIN_DECLS
41be04fec4SKyle Evans
42e5551250SKyle Evans #ifndef _FORTIFY_SOURCE_read
43e5551250SKyle Evans #define _FORTIFY_SOURCE_read read
44e5551250SKyle Evans #endif
45e5551250SKyle Evans
46*cf8e5289SKyle Evans __ssp_inline size_t
__ssp_gid_bos(const void * ptr)47*cf8e5289SKyle Evans __ssp_gid_bos(const void *ptr)
48*cf8e5289SKyle Evans {
49*cf8e5289SKyle Evans size_t ptrsize = __ssp_bos(ptr);
50*cf8e5289SKyle Evans
51*cf8e5289SKyle Evans if (ptrsize == (size_t)-1)
52*cf8e5289SKyle Evans return (ptrsize);
53*cf8e5289SKyle Evans
54*cf8e5289SKyle Evans return (ptrsize / sizeof(gid_t));
55*cf8e5289SKyle Evans }
56*cf8e5289SKyle Evans
57*cf8e5289SKyle Evans __ssp_redirect_raw(int, getgrouplist, getgrouplist,
58*cf8e5289SKyle Evans (const char *__name, gid_t __base, gid_t *__buf, int *__lenp),
59*cf8e5289SKyle Evans (__name, __base, __buf, __lenp), 1, __ssp_gid_bos, *__lenp);
60*cf8e5289SKyle Evans
61*cf8e5289SKyle Evans __ssp_redirect_raw(int, getgroups, getgroups, (int __len, gid_t *__buf),
62*cf8e5289SKyle Evans (__len, __buf), 1, __ssp_gid_bos, __len);
63*cf8e5289SKyle Evans
64*cf8e5289SKyle Evans __ssp_redirect(int, getloginclass, (char *__buf, size_t __len),
65*cf8e5289SKyle Evans (__buf, __len));
66*cf8e5289SKyle Evans
67*cf8e5289SKyle Evans __ssp_redirect(ssize_t, _FORTIFY_SOURCE_read, (int __fd, void *__buf,
68e5551250SKyle Evans size_t __len), (__fd, __buf, __len));
69*cf8e5289SKyle Evans __ssp_redirect(ssize_t, pread, (int __fd, void *__buf, size_t __len,
70*cf8e5289SKyle Evans off_t __offset), (__fd, __buf, __len, __offset));
71be04fec4SKyle Evans
72be04fec4SKyle Evans __ssp_redirect(ssize_t, readlink, (const char *__restrict __path, \
73be04fec4SKyle Evans char *__restrict __buf, size_t __len), (__path, __buf, __len));
74*cf8e5289SKyle Evans __ssp_redirect(ssize_t, readlinkat, (int __fd, const char *__restrict __path,
75*cf8e5289SKyle Evans char *__restrict __buf, size_t __len), (__fd, __path, __buf, __len));
76be04fec4SKyle Evans
77be04fec4SKyle Evans __ssp_redirect_raw(char *, getcwd, getcwd, (char *__buf, size_t __len),
78*cf8e5289SKyle Evans (__buf, __len), __buf != 0, __ssp_bos, __len);
79*cf8e5289SKyle Evans
80*cf8e5289SKyle Evans __ssp_redirect(int, getdomainname, (char *__buf, int __len), (__buf, __len));
81*cf8e5289SKyle Evans __ssp_redirect(int, getentropy, (void *__buf, size_t __len), (__buf, __len));
82*cf8e5289SKyle Evans __ssp_redirect(int, gethostname, (char *__buf, size_t __len), (__buf, __len));
83*cf8e5289SKyle Evans __ssp_redirect(int, getlogin_r, (char *__buf, size_t __len), (__buf, __len));
84*cf8e5289SKyle Evans __ssp_redirect(int, ttyname_r, (int __fd, char *__buf, size_t __len),
85*cf8e5289SKyle Evans (__fd, __buf, __len));
86be04fec4SKyle Evans
87be04fec4SKyle Evans __END_DECLS
88be04fec4SKyle Evans
89be04fec4SKyle Evans #endif /* __SSP_FORTIFY_LEVEL > 0 */
90be04fec4SKyle Evans #endif /* _SSP_UNISTD_H_ */
91