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