xref: /freebsd/include/ssp/stdlib.h (revision d0b7445904f592bf379d64932fb6f1fdc29c4aa7)
1*d0b74459SKyle Evans /*-
2*d0b74459SKyle Evans  * SPDX-License-Identifier: BSD-2-Clause
3*d0b74459SKyle Evans  *
4*d0b74459SKyle Evans  * Copyright (c) 2024, Klara, Inc.
5*d0b74459SKyle Evans  *
6*d0b74459SKyle Evans  * Redistribution and use in source and binary forms, with or without
7*d0b74459SKyle Evans  * modification, are permitted provided that the following conditions
8*d0b74459SKyle Evans  * are met:
9*d0b74459SKyle Evans  * 1. Redistributions of source code must retain the above copyright
10*d0b74459SKyle Evans  *    notice, this list of conditions and the following disclaimer.
11*d0b74459SKyle Evans  * 2. Redistributions in binary form must reproduce the above copyright
12*d0b74459SKyle Evans  *    notice, this list of conditions and the following disclaimer in the
13*d0b74459SKyle Evans  *    documentation and/or other materials provided with the distribution.
14*d0b74459SKyle Evans  *
15*d0b74459SKyle Evans  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16*d0b74459SKyle Evans  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17*d0b74459SKyle Evans  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18*d0b74459SKyle Evans  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19*d0b74459SKyle Evans  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20*d0b74459SKyle Evans  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21*d0b74459SKyle Evans  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22*d0b74459SKyle Evans  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23*d0b74459SKyle Evans  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24*d0b74459SKyle Evans  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25*d0b74459SKyle Evans  * POSSIBILITY OF SUCH DAMAGE.
26*d0b74459SKyle Evans  */
27*d0b74459SKyle Evans #ifndef _SSP_STDLIB_H_
28*d0b74459SKyle Evans #define _SSP_STDLIB_H_
29*d0b74459SKyle Evans 
30*d0b74459SKyle Evans #include <ssp/ssp.h>
31*d0b74459SKyle Evans 
32*d0b74459SKyle Evans #if __SSP_FORTIFY_LEVEL > 0
33*d0b74459SKyle Evans 
34*d0b74459SKyle Evans #include <limits.h>
35*d0b74459SKyle Evans 
36*d0b74459SKyle Evans __BEGIN_DECLS
37*d0b74459SKyle Evans 
38*d0b74459SKyle Evans __ssp_redirect(void, arc4random_buf, (void *__buf, size_t __len),
39*d0b74459SKyle Evans     (__buf, __len));
40*d0b74459SKyle Evans 
41*d0b74459SKyle Evans __ssp_redirect_raw_impl(char *, realpath, realpath,
42*d0b74459SKyle Evans     (const char *__restrict path, char *__restrict buf))
43*d0b74459SKyle Evans {
44*d0b74459SKyle Evans 	if (__ssp_bos(buf) < PATH_MAX)
45*d0b74459SKyle Evans 		__chk_fail();
46*d0b74459SKyle Evans 
47*d0b74459SKyle Evans 	return (__ssp_real(realpath)(path, buf));
48*d0b74459SKyle Evans }
49*d0b74459SKyle Evans 
50*d0b74459SKyle Evans __END_DECLS
51*d0b74459SKyle Evans 
52*d0b74459SKyle Evans #endif /* __SSP_FORTIFY_LEVEL > 0 */
53*d0b74459SKyle Evans #endif /* _SSP_STDLIB_H_ */
54