xref: /freebsd/lib/libssp/fortify_stubs.c (revision a2f733ab)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 2019 Kyle Evans <kevans@FreeBSD.org>
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25  * SUCH DAMAGE.
26  */
27 
28 #include <sys/types.h>
29 
30 #include <stdarg.h>
31 #include <stdlib.h>
32 
33 /* Signatures grabbed from LSB Core Specification 4.1 */
34 void	*__memcpy_chk(void *dst, const void *src, size_t len,
35     size_t dstlen);
36 void	*__memset_chk(void *dst, int c, size_t len, size_t dstlen);
37 int	__snprintf_chk(char *str, size_t maxlen, int flag, size_t strlen,
38     const char *fmt, ...);
39 int	__sprintf_chk(char *str, int flag, size_t strlen, const char *fmt, ...);
40 char	*__stpcpy_chk(char *dst, const char *src, size_t dstlen);
41 char	*__strcat_chk(char *dst, const char *src, size_t dstlen);
42 char	*__strcpy_chk(char *dst, const char *src, size_t dstlen);
43 char	*__strncat_chk(char *dst, const char *src, size_t len, size_t dstlen);
44 char	*__strncpy_chk(char *dst, const char *src, size_t len, size_t dstlen);
45 int	__vsnprintf_chk(char *str, size_t size, int flags, size_t len,
46     const char *format, va_list ap);
47 int	__vsprintf_chk(char *str, int flag, size_t slen, const char *format,
48     va_list ap);
49 
50 #define	ABORT()	abort2("_FORTIFY_SOURCE not supported", 0, NULL)
51 
52 void *
__memcpy_chk(void * dst,const void * src,size_t len,size_t dstlen)53 __memcpy_chk(void *dst, const void *src, size_t len,
54     size_t dstlen)
55 {
56 
57 	ABORT();
58 }
59 
60 void *
__memset_chk(void * dst,int c,size_t len,size_t dstlen)61 __memset_chk(void *dst, int c, size_t len, size_t dstlen)
62 {
63 
64 	ABORT();
65 }
66 
67 int
__snprintf_chk(char * str,size_t maxlen,int flag,size_t strlen,const char * fmt,...)68 __snprintf_chk(char *str, size_t maxlen, int flag, size_t strlen,
69     const char *fmt, ...)
70 {
71 
72 	ABORT();
73 }
74 
75 int
__sprintf_chk(char * str,int flag,size_t strlen,const char * fmt,...)76 __sprintf_chk(char *str, int flag, size_t strlen, const char *fmt, ...)
77 {
78 
79 	ABORT();
80 }
81 
82 char *
__stpcpy_chk(char * dst,const char * src,size_t dstlen)83 __stpcpy_chk(char *dst, const char *src, size_t dstlen)
84 {
85 
86 	ABORT();
87 }
88 
89 char *
__strcat_chk(char * dst,const char * src,size_t dstlen)90 __strcat_chk(char *dst, const char *src, size_t dstlen)
91 {
92 
93 	ABORT();
94 }
95 
96 char *
__strcpy_chk(char * dst,const char * src,size_t dstlen)97 __strcpy_chk(char *dst, const char *src, size_t dstlen)
98 {
99 
100 	ABORT();
101 }
102 
103 char *
__strncat_chk(char * dst,const char * src,size_t len,size_t dstlen)104 __strncat_chk(char *dst, const char *src, size_t len, size_t dstlen)
105 {
106 
107 	ABORT();
108 }
109 
110 char *
__strncpy_chk(char * dst,const char * src,size_t len,size_t dstlen)111 __strncpy_chk(char *dst, const char *src, size_t len, size_t dstlen)
112 {
113 
114 	ABORT();
115 }
116 
117 int
__vsnprintf_chk(char * str,size_t size,int flags,size_t len,const char * format,va_list ap)118 __vsnprintf_chk(char *str, size_t size, int flags, size_t len,
119     const char *format, va_list ap)
120 {
121 
122 	ABORT();
123 }
124 
125 int
__vsprintf_chk(char * str,int flag,size_t slen,const char * format,va_list ap)126 __vsprintf_chk(char *str, int flag, size_t slen, const char *format,
127     va_list ap)
128 {
129 
130 	ABORT();
131 }
132