Re: git: be04fec42638 - main - Import _FORTIFY_SOURCE implementation from NetBSD

From: Kyle Evans <kaevans_at_fastmail.com>
Date: Sat, 18 May 2024 22:54:28 UTC
<div dir='auto'><div><br><div class="gmail_extra"><br><div class="gmail_quote">On May 18, 2024 13:42, Pedro Giffuni &lt;pfg@freebsd.org&gt; wrote:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="font-family:'helvetica neue' , 'helvetica' , 'arial' , sans-serif;font-size:16px"><div></div>
        <div dir="ltr">Oh no .. please not...</div><div dir="ltr"><br></div><div dir="ltr">We went into that in a GSoC:</div><div dir="ltr"><br></div><div dir="ltr"><a href="https://wiki.freebsd.org/SummerOfCode2015/FreeBSDLibcSecurityExtensions">https://wiki.freebsd.org/SummerOfCode2015/FreeBSDLibcSecurityExtensions</a><br></div><div><br></div><div><br></div><div dir="ltr">Ultimately it proved to be useless since stack-protector-strong.</div></div></div></blockquote></div></div></div><div dir="auto"><br></div><div dir="auto">Respectfully, I disagree with your conclusion here:</div><div dir="auto"><br></div><div dir="auto">1.) _FORTIFY_SOURCE provides more granular detection of overflow; I don't have to overflow all the way into the canary at the end of the frame to be detected, so my minor bug now can be caught before something causes the stack frame to be rearranged and turn it into a security issue later</div><div dir="auto"><br></div><div dir="auto">2.) __builtin_object_size doesn't work on heap objects, but it actually can work on subobjects from a heap allocation (e.g., &amp;foo-&gt;name), so the coverage extends beyond the stack into starting to detect other kinds of overflow&nbsp;</div><div dir="auto"><br></div><div dir="auto">While the security value over stack-protector-strong may be marginal (I won't debate this specifically), the feature still has value in general.</div><div dir="auto"><br></div><div dir="auto">Thanks,</div><div dir="auto"><br></div><div dir="auto">Kyle Evans</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="font-family:'helvetica neue' , 'helvetica' , 'arial' , sans-serif;font-size:16px"><div dir="ltr">The NetBSD code was not well adapted to clang either.</div><div dir="ltr"><br></div><div dir="ltr">Ask me more if you really want to dig into it, but we don't want this.</div><div dir="ltr"><br></div><div dir="ltr">Pedro.</div><div><br></div><div><br></div>
        
        </div><div>
            <div style="font-family:'helvetica neue' , 'helvetica' , 'arial' , sans-serif;font-size:13px;color:#26282a">
                
                <div>
                        On Monday, May 13, 2024 at 12:24:13 AM GMT-5, Kyle Evans &lt;kevans@freebsd.org&gt; wrote:
                    </div>
                    <div><br></div>
                    <div><br></div>
                
                
                <div><div dir="ltr">The branch main has been updated by kevans:<br></div><div dir="ltr"><br></div><div dir="ltr">URL: <a href="https://cgit.FreeBSD.org/src/commit/?id=be04fec42638f30f50b5b55fd8e3634c0fb89928">https://cgit.FreeBSD.org/src/commit/?id=be04fec42638f30f50b5b55fd8e3634c0fb89928</a><br></div><div dir="ltr"><br></div><div dir="ltr">commit be04fec42638f30f50b5b55fd8e3634c0fb89928<br></div><div dir="ltr">Author:&nbsp; &nbsp;  Kyle Evans &lt;<a href="mailto:kevans@FreeBSD.org">kevans@FreeBSD.org</a>&gt;<br></div><div dir="ltr">AuthorDate: 2024-05-13 05:23:49 +0000<br></div><div dir="ltr">Commit:&nbsp; &nbsp;  Kyle Evans &lt;<a href="mailto:kevans@FreeBSD.org">kevans@FreeBSD.org</a>&gt;<br></div><div dir="ltr">CommitDate: 2024-05-13 05:23:49 +0000<br></div><div dir="ltr"><br></div><div dir="ltr">&nbsp; &nbsp; Import _FORTIFY_SOURCE implementation from NetBSD<br></div><div dir="ltr">&nbsp; &nbsp; <br></div><div dir="ltr">&nbsp; &nbsp; This is a mostly-unmodified copy of the various *_chk implementations<br></div><div dir="ltr">&nbsp; &nbsp; and headers from NetBSD, without yet modifying system headers to start<br></div><div dir="ltr">&nbsp; &nbsp; actually including them.&nbsp; A future commit will also apply the needed<br></div><div dir="ltr">&nbsp; &nbsp; bits to fix ssp/unistd.h.<br></div><div dir="ltr">&nbsp; &nbsp; <br></div><div dir="ltr">&nbsp; &nbsp; Reviewed by:&nbsp; &nbsp; imp, pauamma_gundo.com (both previous versions), kib<br></div><div dir="ltr">&nbsp; &nbsp; Sponsored by:&nbsp;  Stormshield<br></div><div dir="ltr">&nbsp; &nbsp; Sponsored by:&nbsp;  Klara, Inc.<br></div><div dir="ltr">&nbsp; &nbsp; Differential Revision:&nbsp; <a href="https://reviews.freebsd.org/D32306">https://reviews.freebsd.org/D32306</a><br></div><div dir="ltr">---<br></div><div dir="ltr"> etc/mtree/BSD.include.dist&nbsp; &nbsp; &nbsp; &nbsp;  |&nbsp;  2 +<br></div><div dir="ltr"> include/Makefile&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  |&nbsp;  2 +-<br></div><div dir="ltr"> include/ssp/Makefile&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  |&nbsp;  6 ++<br></div><div dir="ltr"> include/ssp/ssp.h&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |&nbsp; 91 ++++++++++++++++++++++++++<br></div><div dir="ltr"> include/ssp/stdio.h&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |&nbsp; 93 ++++++++++++++++++++++++++<br></div><div dir="ltr"> include/ssp/string.h&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  | 129 ++++++++++++++++++++++++++++++++++++<br></div><div dir="ltr"> include/ssp/strings.h&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |&nbsp; 67 +++++++++++++++++++<br></div><div dir="ltr"> include/ssp/unistd.h&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  |&nbsp; 54 +++++++++++++++<br></div><div dir="ltr"> lib/libc/secure/Makefile.inc&nbsp; &nbsp; &nbsp;  |&nbsp; 11 ++++<br></div><div dir="ltr"> lib/libc/secure/Symbol.map&nbsp; &nbsp; &nbsp; &nbsp;  |&nbsp; 18 +++++<br></div><div dir="ltr"> lib/libc/secure/fgets_chk.c&nbsp; &nbsp; &nbsp; &nbsp; |&nbsp; 54 +++++++++++++++<br></div><div dir="ltr"> lib/libc/secure/gets_chk.c&nbsp; &nbsp; &nbsp; &nbsp;  |&nbsp; 74 +++++++++++++++++++++<br></div><div dir="ltr"> lib/libc/secure/memcpy_chk.c&nbsp; &nbsp; &nbsp;  |&nbsp; 53 +++++++++++++++<br></div><div dir="ltr"> lib/libc/secure/memmove_chk.c&nbsp; &nbsp; &nbsp; |&nbsp; 47 +++++++++++++<br></div><div dir="ltr"> lib/libc/secure/memset_chk.c&nbsp; &nbsp; &nbsp;  |&nbsp; 46 +++++++++++++<br></div><div dir="ltr"> lib/libc/secure/snprintf_chk.c&nbsp; &nbsp;  |&nbsp; 56 ++++++++++++++++<br></div><div dir="ltr"> lib/libc/secure/sprintf_chk.c&nbsp; &nbsp; &nbsp; |&nbsp; 61 +++++++++++++++++<br></div><div dir="ltr"> lib/libc/secure/ssp_internal.h&nbsp; &nbsp;  |&nbsp; 37 +++++++++++<br></div><div dir="ltr"> lib/libc/secure/stpcpy_chk.c&nbsp; &nbsp; &nbsp;  |&nbsp; 55 ++++++++++++++++<br></div><div dir="ltr"> lib/libc/secure/stpncpy_chk.c&nbsp; &nbsp; &nbsp; |&nbsp; 53 +++++++++++++++<br></div><div dir="ltr"> lib/libc/secure/strcat_chk.c&nbsp; &nbsp; &nbsp;  |&nbsp; 60 +++++++++++++++++<br></div><div dir="ltr"> lib/libc/secure/strcpy_chk.c&nbsp; &nbsp; &nbsp;  |&nbsp; 54 +++++++++++++++<br></div><div dir="ltr"> lib/libc/secure/strncat_chk.c&nbsp; &nbsp; &nbsp; |&nbsp; 70 ++++++++++++++++++++<br></div><div dir="ltr"> lib/libc/secure/strncpy_chk.c&nbsp; &nbsp; &nbsp; |&nbsp; 53 +++++++++++++++<br></div><div dir="ltr"> lib/libc/secure/vsnprintf_chk.c&nbsp; &nbsp; |&nbsp; 49 ++++++++++++++<br></div><div dir="ltr"> lib/libc/secure/vsprintf_chk.c&nbsp; &nbsp;  |&nbsp; 58 ++++++++++++++++<br></div><div dir="ltr"> lib/libssp/Makefile&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |&nbsp; 20 +++++-<br></div><div dir="ltr"> lib/libssp/Symbol.map&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |&nbsp; 12 ++--<br></div><div dir="ltr"> lib/libssp/Versions.def&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |&nbsp;  5 ++<br></div><div dir="ltr"> lib/libssp/__builtin_object_size.3 | 110 +++++++++++++++++++++++++++++++<br></div><div dir="ltr"> lib/libssp/fortify_stubs.c&nbsp; &nbsp; &nbsp; &nbsp;  | 131 -------------------------------------<br></div><div dir="ltr"> lib/libssp/ssp.3&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  | 130 ++++++++++++++++++++++++++++++++++++<br></div><div dir="ltr"> 32 files changed, 1621 insertions(+), 140 deletions(-)<br></div><div dir="ltr"><br></div><div dir="ltr">diff --git a/etc/mtree/BSD.include.dist b/etc/mtree/BSD.include.dist<br></div><div dir="ltr">index a6bd5880bf61..f8c83d6dde7a 100644<br></div><div dir="ltr">--- a/etc/mtree/BSD.include.dist<br></div><div dir="ltr">+++ b/etc/mtree/BSD.include.dist<br></div><div dir="ltr">@@ -372,6 +372,8 @@<br></div><div dir="ltr">&nbsp; &nbsp; &nbsp; &nbsp;  mac_veriexec<br></div><div dir="ltr">&nbsp; &nbsp; &nbsp; &nbsp;  ..<br></div><div dir="ltr">&nbsp; &nbsp;  ..<br></div><div dir="ltr">+&nbsp; &nbsp; ssp<br></div><div dir="ltr">+&nbsp; &nbsp; ..<br></div><div dir="ltr">&nbsp; &nbsp;  sys<br></div><div dir="ltr">&nbsp; &nbsp; &nbsp; &nbsp;  disk<br></div><div dir="ltr">&nbsp; &nbsp; &nbsp; &nbsp;  ..<br></div><div dir="ltr">diff --git a/include/Makefile b/include/Makefile<br></div><div dir="ltr">index 19e6beb95203..32774419f162 100644<br></div><div dir="ltr">--- a/include/Makefile<br></div><div dir="ltr">+++ b/include/Makefile<br></div><div dir="ltr">@@ -4,7 +4,7 @@<br></div><div dir="ltr"> <br></div><div dir="ltr"> PACKAGE=clibs<br></div><div dir="ltr"> CLEANFILES= osreldate.h version<br></div><div dir="ltr">-SUBDIR= arpa protocols rpcsvc rpc xlocale<br></div><div dir="ltr">+SUBDIR= arpa protocols rpcsvc rpc ssp xlocale<br></div><div dir="ltr"> .if ${MACHINE_CPUARCH} == "amd64"<br></div><div dir="ltr"> SUBDIR+=&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; i386<br></div><div dir="ltr"> INCLUDE_SUBDIRS+=&nbsp;&nbsp;&nbsp; i386<br></div><div dir="ltr">diff --git a/include/ssp/Makefile b/include/ssp/Makefile<br></div><div dir="ltr">new file mode 100644<br></div><div dir="ltr">index 000000000000..dff19f43c920<br></div><div dir="ltr">--- /dev/null<br></div><div dir="ltr">+++ b/include/ssp/Makefile<br></div><div dir="ltr">@@ -0,0 +1,6 @@<br></div><div dir="ltr">+# $FreeBSD$<br></div><div dir="ltr">+<br></div><div dir="ltr">+INCS=&nbsp;&nbsp;&nbsp; ssp.h stdio.h string.h strings.h unistd.h<br></div><div dir="ltr">+INCSDIR=&nbsp;&nbsp;&nbsp; ${INCLUDEDIR}/ssp<br></div><div dir="ltr">+<br></div><div dir="ltr">+.include &lt;bsd.prog.mk&gt;<br></div><div dir="ltr">diff --git a/include/ssp/ssp.h b/include/ssp/ssp.h<br></div><div dir="ltr">new file mode 100644<br></div><div dir="ltr">index 000000000000..35a9aeee02df<br></div><div dir="ltr">--- /dev/null<br></div><div dir="ltr">+++ b/include/ssp/ssp.h<br></div><div dir="ltr">@@ -0,0 +1,91 @@<br></div><div dir="ltr">+/*&nbsp;&nbsp;&nbsp; $NetBSD: ssp.h,v 1.13 2015/09/03 20:43:47 plunky Exp $&nbsp;&nbsp;&nbsp; */<br></div><div dir="ltr">+<br></div><div dir="ltr">+/*-<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * SPDX-License-Identifier: BSD-2-Clause<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * Copyright (c) 2006, 2011 The NetBSD Foundation, Inc.<br></div><div dir="ltr">+ * All rights reserved.<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * This code is derived from software contributed to The NetBSD Foundation<br></div><div dir="ltr">+ * by Christos Zoulas.<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * Redistribution and use in source and binary forms, with or without<br></div><div dir="ltr">+ * modification, are permitted provided that the following conditions<br></div><div dir="ltr">+ * are met:<br></div><div dir="ltr">+ * 1. Redistributions of source code must retain the above copyright<br></div><div dir="ltr">+ *&nbsp; &nbsp; notice, this list of conditions and the following disclaimer.<br></div><div dir="ltr">+ * 2. Redistributions in binary form must reproduce the above copyright<br></div><div dir="ltr">+ *&nbsp; &nbsp; notice, this list of conditions and the following disclaimer in the<br></div><div dir="ltr">+ *&nbsp; &nbsp; documentation and/or other materials provided with the distribution.<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS<br></div><div dir="ltr">+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED<br></div><div dir="ltr">+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR<br></div><div dir="ltr">+ * PURPOSE ARE DISCLAIMED.&nbsp; IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS<br></div><div dir="ltr">+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR<br></div><div dir="ltr">+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF<br></div><div dir="ltr">+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS<br></div><div dir="ltr">+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN<br></div><div dir="ltr">+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)<br></div><div dir="ltr">+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE<br></div><div dir="ltr">+ * POSSIBILITY OF SUCH DAMAGE.<br></div><div dir="ltr">+ */<br></div><div dir="ltr">+#ifndef _SSP_SSP_H_<br></div><div dir="ltr">+#define _SSP_SSP_H_<br></div><div dir="ltr">+<br></div><div dir="ltr">+#include &lt;sys/cdefs.h&gt;<br></div><div dir="ltr">+<br></div><div dir="ltr">+#if !defined(__cplusplus)<br></div><div dir="ltr">+# if defined(_FORTIFY_SOURCE) &amp;&amp; _FORTIFY_SOURCE &gt; 0 &amp;&amp; \<br></div><div dir="ltr">+&nbsp; &nbsp;  (__OPTIMIZE__ &gt; 0 || defined(__clang__))<br></div><div dir="ltr">+#&nbsp; if _FORTIFY_SOURCE &gt; 1<br></div><div dir="ltr">+#&nbsp;  define __SSP_FORTIFY_LEVEL 2<br></div><div dir="ltr">+#&nbsp; else<br></div><div dir="ltr">+#&nbsp;  define __SSP_FORTIFY_LEVEL 1<br></div><div dir="ltr">+#&nbsp; endif<br></div><div dir="ltr">+# else<br></div><div dir="ltr">+#&nbsp; define __SSP_FORTIFY_LEVEL 0<br></div><div dir="ltr">+# endif<br></div><div dir="ltr">+#else<br></div><div dir="ltr">+# define __SSP_FORTIFY_LEVEL 0<br></div><div dir="ltr">+#endif<br></div><div dir="ltr">+<br></div><div dir="ltr">+#define&nbsp;&nbsp;&nbsp; __ssp_var(type)&nbsp;&nbsp;&nbsp; __CONCAT(__ssp_ ## type, __COUNTER__)<br></div><div dir="ltr">+<br></div><div dir="ltr">+/* __ssp_real is used by the implementation in libc */<br></div><div dir="ltr">+#if __SSP_FORTIFY_LEVEL == 0<br></div><div dir="ltr">+#define __ssp_real_(fun)&nbsp;&nbsp;&nbsp; fun<br></div><div dir="ltr">+#else<br></div><div dir="ltr">+#define __ssp_real_(fun)&nbsp;&nbsp;&nbsp; __ssp_real_ ## fun<br></div><div dir="ltr">+#endif<br></div><div dir="ltr">+#define __ssp_real(fun)&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; __ssp_real_(fun)<br></div><div dir="ltr">+<br></div><div dir="ltr">+#define __ssp_inline static __inline __attribute__((__always_inline__))<br></div><div dir="ltr">+<br></div><div dir="ltr">+#define __ssp_bos(ptr) __builtin_object_size(ptr, __SSP_FORTIFY_LEVEL &gt; 1)<br></div><div dir="ltr">+#define __ssp_bos0(ptr) __builtin_object_size(ptr, 0)<br></div><div dir="ltr">+<br></div><div dir="ltr">+#define __ssp_check(buf, len, bos) \<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; if (bos(buf) != (size_t)-1 &amp;&amp; len &gt; bos(buf)) \<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; __chk_fail()<br></div><div dir="ltr">+#define __ssp_redirect_raw(rtype, fun, symbol, args, call, cond, bos) \<br></div><div dir="ltr">+rtype __ssp_real_(fun) args __RENAME(symbol); \<br></div><div dir="ltr">+__ssp_inline rtype fun args __RENAME(__ssp_protected_ ## fun); \<br></div><div dir="ltr">+__ssp_inline rtype fun args { \<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; if (cond) \<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; __ssp_check(__buf, __len, bos); \<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; return __ssp_real_(fun) call; \<br></div><div dir="ltr">+}<br></div><div dir="ltr">+<br></div><div dir="ltr">+#define __ssp_redirect(rtype, fun, args, call) \<br></div><div dir="ltr">+&nbsp; &nbsp; __ssp_redirect_raw(rtype, fun, fun, args, call, 1, __ssp_bos)<br></div><div dir="ltr">+#define __ssp_redirect0(rtype, fun, args, call) \<br></div><div dir="ltr">+&nbsp; &nbsp; __ssp_redirect_raw(rtype, fun, fun, args, call, 1, __ssp_bos0)<br></div><div dir="ltr">+<br></div><div dir="ltr">+__BEGIN_DECLS<br></div><div dir="ltr">+void __stack_chk_fail(void) __dead2;<br></div><div dir="ltr">+void __chk_fail(void) __dead2;<br></div><div dir="ltr">+__END_DECLS<br></div><div dir="ltr">+<br></div><div dir="ltr">+#endif /* _SSP_SSP_H_ */<br></div><div dir="ltr">diff --git a/include/ssp/stdio.h b/include/ssp/stdio.h<br></div><div dir="ltr">new file mode 100644<br></div><div dir="ltr">index 000000000000..72e3236eac80<br></div><div dir="ltr">--- /dev/null<br></div><div dir="ltr">+++ b/include/ssp/stdio.h<br></div><div dir="ltr">@@ -0,0 +1,93 @@<br></div><div dir="ltr">+/*&nbsp;&nbsp;&nbsp; $NetBSD: stdio.h,v 1.5 2011/07/17 20:54:34 joerg Exp $&nbsp;&nbsp;&nbsp; */<br></div><div dir="ltr">+<br></div><div dir="ltr">+/*-<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * SPDX-License-Identifier: BSD-2-Clause<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * Copyright (c) 2006 The NetBSD Foundation, Inc.<br></div><div dir="ltr">+ * All rights reserved.<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * This code is derived from software contributed to The NetBSD Foundation<br></div><div dir="ltr">+ * by Christos Zoulas.<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * Redistribution and use in source and binary forms, with or without<br></div><div dir="ltr">+ * modification, are permitted provided that the following conditions<br></div><div dir="ltr">+ * are met:<br></div><div dir="ltr">+ * 1. Redistributions of source code must retain the above copyright<br></div><div dir="ltr">+ *&nbsp; &nbsp; notice, this list of conditions and the following disclaimer.<br></div><div dir="ltr">+ * 2. Redistributions in binary form must reproduce the above copyright<br></div><div dir="ltr">+ *&nbsp; &nbsp; notice, this list of conditions and the following disclaimer in the<br></div><div dir="ltr">+ *&nbsp; &nbsp; documentation and/or other materials provided with the distribution.<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS<br></div><div dir="ltr">+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED<br></div><div dir="ltr">+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR<br></div><div dir="ltr">+ * PURPOSE ARE DISCLAIMED.&nbsp; IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS<br></div><div dir="ltr">+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR<br></div><div dir="ltr">+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF<br></div><div dir="ltr">+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS<br></div><div dir="ltr">+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN<br></div><div dir="ltr">+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)<br></div><div dir="ltr">+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE<br></div><div dir="ltr">+ * POSSIBILITY OF SUCH DAMAGE.<br></div><div dir="ltr">+ */<br></div><div dir="ltr">+#ifndef _SSP_STDIO_H_<br></div><div dir="ltr">+#define _SSP_STDIO_H_<br></div><div dir="ltr">+<br></div><div dir="ltr">+#include &lt;ssp/ssp.h&gt;<br></div><div dir="ltr">+<br></div><div dir="ltr">+__BEGIN_DECLS<br></div><div dir="ltr">+int __sprintf_chk(char *__restrict, int, size_t, const char *__restrict, ...)<br></div><div dir="ltr">+&nbsp; &nbsp; __printflike(4, 5);<br></div><div dir="ltr">+int __vsprintf_chk(char *__restrict, int, size_t, const char *__restrict,<br></div><div dir="ltr">+&nbsp; &nbsp; __va_list)<br></div><div dir="ltr">+&nbsp; &nbsp; __printflike(4, 0);<br></div><div dir="ltr">+int __snprintf_chk(char *__restrict, size_t, int, size_t,<br></div><div dir="ltr">+&nbsp; &nbsp; const char *__restrict, ...)<br></div><div dir="ltr">+&nbsp; &nbsp; __printflike(5, 6);<br></div><div dir="ltr">+int __vsnprintf_chk(char *__restrict, size_t, int, size_t,<br></div><div dir="ltr">+&nbsp; &nbsp;  const char *__restrict, __va_list)<br></div><div dir="ltr">+&nbsp; &nbsp; __printflike(5, 0);<br></div><div dir="ltr">+char *__gets_chk(char *, size_t);<br></div><div dir="ltr">+char *__fgets_chk(char *, int, size_t, FILE *);<br></div><div dir="ltr">+__END_DECLS<br></div><div dir="ltr">+<br></div><div dir="ltr">+#if __SSP_FORTIFY_LEVEL &gt; 0<br></div><div dir="ltr">+<br></div><div dir="ltr">+#define sprintf(str, ...) ({&nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+&nbsp; &nbsp; char *_ssp_str = (str);&nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+&nbsp; &nbsp; __builtin___sprintf_chk(_ssp_str, 0, __ssp_bos(_ssp_str),&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+&nbsp; &nbsp; &nbsp; &nbsp; __VA_ARGS__); \<br></div><div dir="ltr">+})<br></div><div dir="ltr">+<br></div><div dir="ltr">+#define vsprintf(str, fmt, ap) ({&nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+&nbsp; &nbsp; char *_ssp_str = (str);&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+&nbsp; &nbsp; __builtin___vsprintf_chk(_ssp_str, 0, __ssp_bos(_ssp_str), fmt,&nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+&nbsp; &nbsp; &nbsp; &nbsp; ap);&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+})<br></div><div dir="ltr">+<br></div><div dir="ltr">+#define snprintf(str, len, ...) ({&nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+&nbsp; &nbsp; char *_ssp_str = (str);&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+&nbsp; &nbsp; __builtin___snprintf_chk(_ssp_str, len, 0, __ssp_bos(_ssp_str),&nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+&nbsp; &nbsp; &nbsp; &nbsp; __VA_ARGS__);&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+})<br></div><div dir="ltr">+<br></div><div dir="ltr">+#define vsnprintf(str, len, fmt, ap) ({&nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+&nbsp; &nbsp; char *_ssp_str = (str);&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+&nbsp; &nbsp; __builtin___vsnprintf_chk(_ssp_str, len, 0, __ssp_bos(_ssp_str),&nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+&nbsp; &nbsp; &nbsp; &nbsp; fmt, ap);&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+})<br></div><div dir="ltr">+<br></div><div dir="ltr">+#define gets(str) ({&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+&nbsp;  char *_ssp_str = (str);&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+&nbsp; &nbsp; __gets_chk(_ssp_str, __ssp_bos(_ssp_str));&nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+})<br></div><div dir="ltr">+<br></div><div dir="ltr">+#define fgets(str, len, fp) ({&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+&nbsp; &nbsp; char *_ssp_str = (str);&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+&nbsp; &nbsp; __fgets_chk(_ssp_str, len, __ssp_bos(_ssp_str), fp);&nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+})<br></div><div dir="ltr">+<br></div><div dir="ltr">+#endif /* __SSP_FORTIFY_LEVEL &gt; 0 */<br></div><div dir="ltr">+<br></div><div dir="ltr">+#endif /* _SSP_STDIO_H_ */<br></div><div dir="ltr">diff --git a/include/ssp/string.h b/include/ssp/string.h<br></div><div dir="ltr">new file mode 100644<br></div><div dir="ltr">index 000000000000..996020fda778<br></div><div dir="ltr">--- /dev/null<br></div><div dir="ltr">+++ b/include/ssp/string.h<br></div><div dir="ltr">@@ -0,0 +1,129 @@<br></div><div dir="ltr">+/*&nbsp;&nbsp;&nbsp; $NetBSD: string.h,v 1.14 2020/09/05 13:37:59 mrg Exp $&nbsp;&nbsp;&nbsp; */<br></div><div dir="ltr">+<br></div><div dir="ltr">+/*-<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * SPDX-License-Identifier: BSD-2-Clause<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * Copyright (c) 2006 The NetBSD Foundation, Inc.<br></div><div dir="ltr">+ * All rights reserved.<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * This code is derived from software contributed to The NetBSD Foundation<br></div><div dir="ltr">+ * by Christos Zoulas.<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * Redistribution and use in source and binary forms, with or without<br></div><div dir="ltr">+ * modification, are permitted provided that the following conditions<br></div><div dir="ltr">+ * are met:<br></div><div dir="ltr">+ * 1. Redistributions of source code must retain the above copyright<br></div><div dir="ltr">+ *&nbsp; &nbsp; notice, this list of conditions and the following disclaimer.<br></div><div dir="ltr">+ * 2. Redistributions in binary form must reproduce the above copyright<br></div><div dir="ltr">+ *&nbsp; &nbsp; notice, this list of conditions and the following disclaimer in the<br></div><div dir="ltr">+ *&nbsp; &nbsp; documentation and/or other materials provided with the distribution.<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS<br></div><div dir="ltr">+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED<br></div><div dir="ltr">+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR<br></div><div dir="ltr">+ * PURPOSE ARE DISCLAIMED.&nbsp; IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS<br></div><div dir="ltr">+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR<br></div><div dir="ltr">+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF<br></div><div dir="ltr">+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS<br></div><div dir="ltr">+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN<br></div><div dir="ltr">+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)<br></div><div dir="ltr">+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE<br></div><div dir="ltr">+ * POSSIBILITY OF SUCH DAMAGE.<br></div><div dir="ltr">+ */<br></div><div dir="ltr">+#ifndef _SSP_STRING_H_<br></div><div dir="ltr">+#define _SSP_STRING_H_<br></div><div dir="ltr">+<br></div><div dir="ltr">+#include &lt;ssp/ssp.h&gt;<br></div><div dir="ltr">+<br></div><div dir="ltr">+__BEGIN_DECLS<br></div><div dir="ltr">+void *__memcpy_chk(void *, const void *, size_t, size_t);<br></div><div dir="ltr">+void *__memmove_chk(void *, const void *, size_t, size_t);<br></div><div dir="ltr">+void *__memset_chk(void *, int, size_t, size_t);<br></div><div dir="ltr">+char *__stpcpy_chk(char *, const char *, size_t);<br></div><div dir="ltr">+char *__stpncpy_chk(char *, const char *, size_t, size_t);<br></div><div dir="ltr">+char *__strcat_chk(char *, const char *, size_t);<br></div><div dir="ltr">+char *__strcpy_chk(char *, const char *, size_t);<br></div><div dir="ltr">+char *__strncat_chk(char *, const char *, size_t, size_t);<br></div><div dir="ltr">+char *__strncpy_chk(char *, const char *, size_t, size_t);<br></div><div dir="ltr">+__END_DECLS<br></div><div dir="ltr">+<br></div><div dir="ltr">+#if __SSP_FORTIFY_LEVEL &gt; 0<br></div><div dir="ltr">+<br></div><div dir="ltr">+#define __ssp_bos_check3_typed_var(fun, dsttype, dsrvar, dst, srctype, srcvar, \<br></div><div dir="ltr">+&nbsp; &nbsp; src, lenvar, len) ({&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+&nbsp; &nbsp; srctype srcvar = (src);&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+&nbsp; &nbsp; dsttype dstvar = (dst);&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+&nbsp; &nbsp; size_t lenvar = (len);&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+&nbsp; &nbsp; ((__ssp_bos0(dstvar) != (size_t)-1) ?&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+&nbsp; &nbsp; __builtin___ ## fun ## _chk(dstvar, srcvar, lenvar,&nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+&nbsp; &nbsp; &nbsp; &nbsp; __ssp_bos0(dstvar)) :&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+&nbsp; &nbsp; __ ## fun ## _ichk(dstvar, srcvar, lenvar));&nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+})<br></div><div dir="ltr">+<br></div><div dir="ltr">+#define __ssp_bos_check3_typed(fun, dsttype, dst, srctype, src, len)&nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+&nbsp; &nbsp; __ssp_bos_check3_typed_var(fun, dsttype, __ssp_var(dstv), dst,&nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+&nbsp; &nbsp; &nbsp; &nbsp; srctype, __ssp_var(srcv), src, __ssp_var(lenv), len)<br></div><div dir="ltr">+<br></div><div dir="ltr">+#define __ssp_bos_check3(fun, dst, src, len)&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+&nbsp; &nbsp; __ssp_bos_check3_typed_var(fun, void *, __ssp_var(dstv), dst,&nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+&nbsp; &nbsp; &nbsp; &nbsp; const void *, __ssp_var(srcv), src, __ssp_var(lenv), len)<br></div><div dir="ltr">+<br></div><div dir="ltr">+#define __ssp_bos_check2_var(fun, dstvar, dst, srcvar, src) ({&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+&nbsp; &nbsp; const void *srcvar = (src);&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+&nbsp; &nbsp; void *dstvar = (dst);&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+&nbsp; &nbsp; ((__ssp_bos0(dstvar) != (size_t)-1) ?&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+&nbsp; &nbsp; __builtin___ ## fun ## _chk(dstvar, srcvar,&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+&nbsp; &nbsp; &nbsp; &nbsp; __ssp_bos0(dstvar)) :&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+&nbsp; &nbsp; __ ## fun ## _ichk(dstvar, srcvar));&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+})<br></div><div dir="ltr">+<br></div><div dir="ltr">+#define __ssp_bos_check2(fun, dst, src)&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+&nbsp; &nbsp; __ssp_bos_check2_var(fun, __ssp_var(dstv), dst, __ssp_var(srcv), src)<br></div><div dir="ltr">+<br></div><div dir="ltr">+#define __ssp_bos_icheck3_restrict(fun, type1, type2) \<br></div><div dir="ltr">+static __inline type1 __ ## fun ## _ichk(type1 __restrict, type2 __restrict, size_t); \<br></div><div dir="ltr">+static __inline __attribute__((__always_inline__)) type1 \<br></div><div dir="ltr">+__ ## fun ## _ichk(type1 __restrict dst, type2 __restrict src, size_t len) { \<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; return __builtin___ ## fun ## _chk(dst, src, len, __ssp_bos0(dst)); \<br></div><div dir="ltr">+}<br></div><div dir="ltr">+<br></div><div dir="ltr">+#define __ssp_bos_icheck3(fun, type1, type2) \<br></div><div dir="ltr">+static __inline type1 __ ## fun ## _ichk(type1, type2, size_t); \<br></div><div dir="ltr">+static __inline __attribute__((__always_inline__)) type1 \<br></div><div dir="ltr">+__ ## fun ## _ichk(type1 dst, type2 src, size_t len) { \<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; return __builtin___ ## fun ## _chk(dst, src, len, __ssp_bos0(dst)); \<br></div><div dir="ltr">+}<br></div><div dir="ltr">+<br></div><div dir="ltr">+#define __ssp_bos_icheck2_restrict(fun, type1, type2) \<br></div><div dir="ltr">+static __inline type1 __ ## fun ## _ichk(type1, type2); \<br></div><div dir="ltr">+static __inline __attribute__((__always_inline__)) type1 \<br></div><div dir="ltr">+__ ## fun ## _ichk(type1 __restrict dst, type2 __restrict src) { \<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; return __builtin___ ## fun ## _chk(dst, src, __ssp_bos0(dst)); \<br></div><div dir="ltr">+}<br></div><div dir="ltr">+<br></div><div dir="ltr">+__BEGIN_DECLS<br></div><div dir="ltr">+__ssp_bos_icheck3_restrict(memcpy, void *, const void *)<br></div><div dir="ltr">+__ssp_bos_icheck3(memmove, void *, const void *)<br></div><div dir="ltr">+__ssp_bos_icheck3(memset, void *, int)<br></div><div dir="ltr">+__ssp_bos_icheck2_restrict(stpcpy, char *, const char *)<br></div><div dir="ltr">+__ssp_bos_icheck3_restrict(stpncpy, char *, const char *)<br></div><div dir="ltr">+__ssp_bos_icheck2_restrict(strcpy, char *, const char *)<br></div><div dir="ltr">+__ssp_bos_icheck2_restrict(strcat, char *, const char *)<br></div><div dir="ltr">+__ssp_bos_icheck3_restrict(strncpy, char *, const char *)<br></div><div dir="ltr">+__ssp_bos_icheck3_restrict(strncat, char *, const char *)<br></div><div dir="ltr">+__END_DECLS<br></div><div dir="ltr">+<br></div><div dir="ltr">+#define memcpy(dst, src, len) __ssp_bos_check3(memcpy, dst, src, len)<br></div><div dir="ltr">+#define memmove(dst, src, len) __ssp_bos_check3(memmove, dst, src, len)<br></div><div dir="ltr">+#define memset(dst, val, len) \<br></div><div dir="ltr">+&nbsp; &nbsp; __ssp_bos_check3_typed(memset, void *, dst, int, val, len)<br></div><div dir="ltr">+#define stpcpy(dst, src) __ssp_bos_check2(stpcpy, dst, src)<br></div><div dir="ltr">+#define stpncpy(dst, src, len) __ssp_bos_check3(stpncpy, dst, src, len)<br></div><div dir="ltr">+#define strcpy(dst, src) __ssp_bos_check2(strcpy, dst, src)<br></div><div dir="ltr">+#define strcat(dst, src) __ssp_bos_check2(strcat, dst, src)<br></div><div dir="ltr">+#define strncpy(dst, src, len) __ssp_bos_check3(strncpy, dst, src, len)<br></div><div dir="ltr">+#define strncat(dst, src, len) __ssp_bos_check3(strncat, dst, src, len)<br></div><div dir="ltr">+<br></div><div dir="ltr">+#endif /* __SSP_FORTIFY_LEVEL &gt; 0 */<br></div><div dir="ltr">+#endif /* _SSP_STRING_H_ */<br></div><div dir="ltr">diff --git a/include/ssp/strings.h b/include/ssp/strings.h<br></div><div dir="ltr">new file mode 100644<br></div><div dir="ltr">index 000000000000..06c9c7cc0a09<br></div><div dir="ltr">--- /dev/null<br></div><div dir="ltr">+++ b/include/ssp/strings.h<br></div><div dir="ltr">@@ -0,0 +1,67 @@<br></div><div dir="ltr">+/*&nbsp;&nbsp;&nbsp; $NetBSD: strings.h,v 1.3 2008/04/28 20:22:54 martin Exp $&nbsp;&nbsp;&nbsp; */<br></div><div dir="ltr">+<br></div><div dir="ltr">+/*-<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * SPDX-License-Identifier: BSD-2-Clause<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * Copyright (c) 2007 The NetBSD Foundation, Inc.<br></div><div dir="ltr">+ * All rights reserved.<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * This code is derived from software contributed to The NetBSD Foundation<br></div><div dir="ltr">+ * by Christos Zoulas.<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * Redistribution and use in source and binary forms, with or without<br></div><div dir="ltr">+ * modification, are permitted provided that the following conditions<br></div><div dir="ltr">+ * are met:<br></div><div dir="ltr">+ * 1. Redistributions of source code must retain the above copyright<br></div><div dir="ltr">+ *&nbsp; &nbsp; notice, this list of conditions and the following disclaimer.<br></div><div dir="ltr">+ * 2. Redistributions in binary form must reproduce the above copyright<br></div><div dir="ltr">+ *&nbsp; &nbsp; notice, this list of conditions and the following disclaimer in the<br></div><div dir="ltr">+ *&nbsp; &nbsp; documentation and/or other materials provided with the distribution.<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS<br></div><div dir="ltr">+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED<br></div><div dir="ltr">+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR<br></div><div dir="ltr">+ * PURPOSE ARE DISCLAIMED.&nbsp; IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS<br></div><div dir="ltr">+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR<br></div><div dir="ltr">+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF<br></div><div dir="ltr">+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS<br></div><div dir="ltr">+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN<br></div><div dir="ltr">+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)<br></div><div dir="ltr">+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE<br></div><div dir="ltr">+ * POSSIBILITY OF SUCH DAMAGE.<br></div><div dir="ltr">+ */<br></div><div dir="ltr">+#ifndef _SSP_STRINGS_H_<br></div><div dir="ltr">+#define _SSP_STRINGS_H_<br></div><div dir="ltr">+<br></div><div dir="ltr">+#include &lt;ssp/ssp.h&gt;<br></div><div dir="ltr">+#include &lt;string.h&gt;<br></div><div dir="ltr">+<br></div><div dir="ltr">+#if __SSP_FORTIFY_LEVEL &gt; 0<br></div><div dir="ltr">+<br></div><div dir="ltr">+#define _ssp_bcopy(srcvar, src, dstvar, dst, lenvar,&nbsp; len) ({&nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+&nbsp; &nbsp; const void *srcvar = (src);&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+&nbsp; &nbsp; void *dstvar = (dst);&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+&nbsp; &nbsp; size_t lenvar = (len);&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+&nbsp; &nbsp; ((__ssp_bos0(dstvar) != (size_t)-1) ?&nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+&nbsp; &nbsp; __builtin___memmove_chk(dstvar, srcvar, lenvar,&nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+&nbsp; &nbsp; &nbsp; &nbsp; __ssp_bos0(dstvar)) :&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+&nbsp; &nbsp; __memmove_ichk(dstvar, srcvar, lenvar));&nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+})<br></div><div dir="ltr">+<br></div><div dir="ltr">+#define&nbsp;&nbsp;&nbsp; bcopy(src, dst, len)&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+&nbsp; &nbsp; _ssp_bcopy(__ssp_var(srcv), src, __ssp_var(dstv), dst, __ssp_var(lenv), len)<br></div><div dir="ltr">+<br></div><div dir="ltr">+#define _ssp_bzero(dstvar, dst, lenvar, len) ({&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+&nbsp; &nbsp; void *dstvar = (dst);&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+&nbsp; &nbsp; size_t lenvar = (len);&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+&nbsp; &nbsp; ((__ssp_bos0(dstvar) != (size_t)-1) ?&nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+&nbsp; &nbsp; __builtin___memset_chk(dstvar, 0, lenvar,&nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+&nbsp; &nbsp; &nbsp; &nbsp; __ssp_bos0(dstvar)) : \<br></div><div dir="ltr">+&nbsp; &nbsp; __memset_ichk(dstvar, 0, lenvar));&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir="ltr">+})<br></div><div dir="ltr">+<br></div><div dir="ltr">+#define&nbsp;&nbsp;&nbsp; bzero(dst, len)&nbsp;&nbsp;&nbsp; _ssp_bzero(__ssp_var(dstv), dst, __ssp_var(lenv), len)<br></div><div dir="ltr">+<br></div><div dir="ltr">+#endif /* __SSP_FORTIFY_LEVEL &gt; 0 */<br></div><div dir="ltr">+#endif /* _SSP_STRINGS_H_ */<br></div><div dir="ltr">diff --git a/include/ssp/unistd.h b/include/ssp/unistd.h<br></div><div dir="ltr">new file mode 100644<br></div><div dir="ltr">index 000000000000..2414e2baa96b<br></div><div dir="ltr">--- /dev/null<br></div><div dir="ltr">+++ b/include/ssp/unistd.h<br></div><div dir="ltr">@@ -0,0 +1,54 @@<br></div><div dir="ltr">+/*&nbsp;&nbsp;&nbsp; $NetBSD: unistd.h,v 1.7 2015/06/25 18:41:03 joerg Exp $&nbsp;&nbsp;&nbsp; */<br></div><div dir="ltr">+<br></div><div dir="ltr">+/*-<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * SPDX-License-Identifier: BSD-2-Clause<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * Copyright (c) 2006 The NetBSD Foundation, Inc.<br></div><div dir="ltr">+ * All rights reserved.<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * This code is derived from software contributed to The NetBSD Foundation<br></div><div dir="ltr">+ * by Christos Zoulas.<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * Redistribution and use in source and binary forms, with or without<br></div><div dir="ltr">+ * modification, are permitted provided that the following conditions<br></div><div dir="ltr">+ * are met:<br></div><div dir="ltr">+ * 1. Redistributions of source code must retain the above copyright<br></div><div dir="ltr">+ *&nbsp; &nbsp; notice, this list of conditions and the following disclaimer.<br></div><div dir="ltr">+ * 2. Redistributions in binary form must reproduce the above copyright<br></div><div dir="ltr">+ *&nbsp; &nbsp; notice, this list of conditions and the following disclaimer in the<br></div><div dir="ltr">+ *&nbsp; &nbsp; documentation and/or other materials provided with the distribution.<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS<br></div><div dir="ltr">+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED<br></div><div dir="ltr">+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR<br></div><div dir="ltr">+ * PURPOSE ARE DISCLAIMED.&nbsp; IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS<br></div><div dir="ltr">+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR<br></div><div dir="ltr">+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF<br></div><div dir="ltr">+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS<br></div><div dir="ltr">+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN<br></div><div dir="ltr">+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)<br></div><div dir="ltr">+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE<br></div><div dir="ltr">+ * POSSIBILITY OF SUCH DAMAGE.<br></div><div dir="ltr">+ */<br></div><div dir="ltr">+#ifndef _SSP_UNISTD_H_<br></div><div dir="ltr">+#define _SSP_UNISTD_H_<br></div><div dir="ltr">+<br></div><div dir="ltr">+#include &lt;ssp/ssp.h&gt;<br></div><div dir="ltr">+<br></div><div dir="ltr">+#if __SSP_FORTIFY_LEVEL &gt; 0<br></div><div dir="ltr">+__BEGIN_DECLS<br></div><div dir="ltr">+<br></div><div dir="ltr">+__ssp_redirect0(ssize_t, read, (int __fd, void *__buf, size_t __len), \<br></div><div dir="ltr">+&nbsp; &nbsp; (__fd, __buf, __len));<br></div><div dir="ltr">+<br></div><div dir="ltr">+__ssp_redirect(ssize_t, readlink, (const char *__restrict __path, \<br></div><div dir="ltr">+&nbsp; &nbsp; char *__restrict __buf, size_t __len), (__path, __buf, __len));<br></div><div dir="ltr">+<br></div><div dir="ltr">+__ssp_redirect_raw(char *, getcwd, getcwd, (char *__buf, size_t __len),<br></div><div dir="ltr">+&nbsp; &nbsp; (__buf, __len), __buf != 0, __ssp_bos);<br></div><div dir="ltr">+<br></div><div dir="ltr">+__END_DECLS<br></div><div dir="ltr">+<br></div><div dir="ltr">+#endif /* __SSP_FORTIFY_LEVEL &gt; 0 */<br></div><div dir="ltr">+#endif /* _SSP_UNISTD_H_ */<br></div><div dir="ltr">diff --git a/lib/libc/secure/Makefile.inc b/lib/libc/secure/Makefile.inc<br></div><div dir="ltr">index 8574c5a05dc5..3b1ad879c715 100644<br></div><div dir="ltr">--- a/lib/libc/secure/Makefile.inc<br></div><div dir="ltr">+++ b/lib/libc/secure/Makefile.inc<br></div><div dir="ltr">@@ -3,6 +3,17 @@<br></div><div dir="ltr"> <br></div><div dir="ltr"> .PATH: ${LIBC_SRCTOP}/secure<br></div><div dir="ltr"> <br></div><div dir="ltr">+# _FORTIFY_SOURCE<br></div><div dir="ltr">+SRCS+=&nbsp;&nbsp;&nbsp; gets_chk.c fgets_chk.c memcpy_chk.c memmove_chk.c memset_chk.c \<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; snprintf_chk.c sprintf_chk.c stpcpy_chk.c stpncpy_chk.c \<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; strcat_chk.c strcpy_chk.c strncat_chk.c strncpy_chk.c \<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; vsnprintf_chk.c vsprintf_chk.c<br></div><div dir="ltr">+<br></div><div dir="ltr">+CFLAGS.snprintf_chk.c+=&nbsp;&nbsp;&nbsp; -Wno-unused-parameter<br></div><div dir="ltr">+CFLAGS.sprintf_chk.c+=&nbsp;&nbsp;&nbsp; -Wno-unused-parameter<br></div><div dir="ltr">+CFLAGS.vsnprintf_chk.c+=&nbsp;&nbsp;&nbsp; -Wno-unused-parameter<br></div><div dir="ltr">+CFLAGS.vsprintf_chk.c+=&nbsp;&nbsp;&nbsp; -Wno-unused-parameter<br></div><div dir="ltr">+<br></div><div dir="ltr"> # Sources common to both syscall interfaces:<br></div><div dir="ltr"> SRCS+=&nbsp;&nbsp;&nbsp; stack_protector.c \<br></div><div dir="ltr"> &nbsp;&nbsp;&nbsp; stack_protector_compat.c<br></div><div dir="ltr">diff --git a/lib/libc/secure/Symbol.map b/lib/libc/secure/Symbol.map<br></div><div dir="ltr">index 641f451b5421..7859fcee3821 100644<br></div><div dir="ltr">--- a/lib/libc/secure/Symbol.map<br></div><div dir="ltr">+++ b/lib/libc/secure/Symbol.map<br></div><div dir="ltr">@@ -3,3 +3,21 @@ FBSD_1.0 {<!-- --><br></div><div dir="ltr"> &nbsp;&nbsp;&nbsp; __stack_chk_fail;<br></div><div dir="ltr"> &nbsp;&nbsp;&nbsp; __stack_chk_guard;<br></div><div dir="ltr"> };<br></div><div dir="ltr">+<br></div><div dir="ltr">+FBSD_1.8 {<!-- --><br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; __gets_chk;<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; __fgets_chk;<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; __memcpy_chk;<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; __memmove_chk;<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; __memset_chk;<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; __snprintf_chk;<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; __sprintf_chk;<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; __stpcpy_chk;<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; __stpncpy_chk;<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; __strcat_chk;<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; __strcpy_chk;<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; __strncat_chk;<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; __strncpy_chk;<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; __vsnprintf_chk;<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; __vsprintf_chk;<br></div><div dir="ltr">+};<br></div><div dir="ltr">diff --git a/lib/libc/secure/fgets_chk.c b/lib/libc/secure/fgets_chk.c<br></div><div dir="ltr">new file mode 100644<br></div><div dir="ltr">index 000000000000..72aa1d816ce1<br></div><div dir="ltr">--- /dev/null<br></div><div dir="ltr">+++ b/lib/libc/secure/fgets_chk.c<br></div><div dir="ltr">@@ -0,0 +1,54 @@<br></div><div dir="ltr">+/*-<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * SPDX-License-Identifier: BSD-2-Clause<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * Copyright (c) 2006 The NetBSD Foundation, Inc.<br></div><div dir="ltr">+ * All rights reserved.<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * This code is derived from software contributed to The NetBSD Foundation<br></div><div dir="ltr">+ * by Christos Zoulas.<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * Redistribution and use in source and binary forms, with or without<br></div><div dir="ltr">+ * modification, are permitted provided that the following conditions<br></div><div dir="ltr">+ * are met:<br></div><div dir="ltr">+ * 1. Redistributions of source code must retain the above copyright<br></div><div dir="ltr">+ *&nbsp; &nbsp; notice, this list of conditions and the following disclaimer.<br></div><div dir="ltr">+ * 2. Redistributions in binary form must reproduce the above copyright<br></div><div dir="ltr">+ *&nbsp; &nbsp; notice, this list of conditions and the following disclaimer in the<br></div><div dir="ltr">+ *&nbsp; &nbsp; documentation and/or other materials provided with the distribution.<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS<br></div><div dir="ltr">+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED<br></div><div dir="ltr">+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR<br></div><div dir="ltr">+ * PURPOSE ARE DISCLAIMED.&nbsp; IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS<br></div><div dir="ltr">+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR<br></div><div dir="ltr">+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF<br></div><div dir="ltr">+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS<br></div><div dir="ltr">+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN<br></div><div dir="ltr">+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)<br></div><div dir="ltr">+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE<br></div><div dir="ltr">+ * POSSIBILITY OF SUCH DAMAGE.<br></div><div dir="ltr">+ */<br></div><div dir="ltr">+#include &lt;sys/cdefs.h&gt;<br></div><div dir="ltr">+__RCSID("$NetBSD: fgets_chk.c,v 1.6 2009/02/05 05:41:51 lukem Exp $");<br></div><div dir="ltr">+<br></div><div dir="ltr">+#include &lt;limits.h&gt;<br></div><div dir="ltr">+#include &lt;stdio.h&gt;<br></div><div dir="ltr">+#include &lt;stdlib.h&gt;<br></div><div dir="ltr">+#include &lt;string.h&gt;<br></div><div dir="ltr">+<br></div><div dir="ltr">+#include &lt;ssp/stdio.h&gt;<br></div><div dir="ltr">+#include &lt;ssp/string.h&gt;<br></div><div dir="ltr">+#undef fgets<br></div><div dir="ltr">+<br></div><div dir="ltr">+char *<br></div><div dir="ltr">+__fgets_chk(char * __restrict buf, int len, size_t slen, FILE *fp)<br></div><div dir="ltr">+{<!-- --><br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; if (slen &gt;= (size_t)INT_MAX)<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return (fgets(buf, len, fp));<br></div><div dir="ltr">+<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; if (len &gt;= 0 &amp;&amp; (size_t)len &gt; slen)<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; __chk_fail();<br></div><div dir="ltr">+<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; return (fgets(buf, len, fp));<br></div><div dir="ltr">+}<br></div><div dir="ltr">diff --git a/lib/libc/secure/gets_chk.c b/lib/libc/secure/gets_chk.c<br></div><div dir="ltr">new file mode 100644<br></div><div dir="ltr">index 000000000000..18c1e2d18f43<br></div><div dir="ltr">--- /dev/null<br></div><div dir="ltr">+++ b/lib/libc/secure/gets_chk.c<br></div><div dir="ltr">@@ -0,0 +1,74 @@<br></div><div dir="ltr">+/*-<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * SPDX-License-Identifier: BSD-2-Clause<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * Copyright (c) 2006 The NetBSD Foundation, Inc.<br></div><div dir="ltr">+ * All rights reserved.<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * This code is derived from software contributed to The NetBSD Foundation<br></div><div dir="ltr">+ * by Christos Zoulas.<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * Redistribution and use in source and binary forms, with or without<br></div><div dir="ltr">+ * modification, are permitted provided that the following conditions<br></div><div dir="ltr">+ * are met:<br></div><div dir="ltr">+ * 1. Redistributions of source code must retain the above copyright<br></div><div dir="ltr">+ *&nbsp; &nbsp; notice, this list of conditions and the following disclaimer.<br></div><div dir="ltr">+ * 2. Redistributions in binary form must reproduce the above copyright<br></div><div dir="ltr">+ *&nbsp; &nbsp; notice, this list of conditions and the following disclaimer in the<br></div><div dir="ltr">+ *&nbsp; &nbsp; documentation and/or other materials provided with the distribution.<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS<br></div><div dir="ltr">+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED<br></div><div dir="ltr">+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR<br></div><div dir="ltr">+ * PURPOSE ARE DISCLAIMED.&nbsp; IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS<br></div><div dir="ltr">+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR<br></div><div dir="ltr">+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF<br></div><div dir="ltr">+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS<br></div><div dir="ltr">+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN<br></div><div dir="ltr">+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)<br></div><div dir="ltr">+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE<br></div><div dir="ltr">+ * POSSIBILITY OF SUCH DAMAGE.<br></div><div dir="ltr">+ */<br></div><div dir="ltr">+#include &lt;sys/cdefs.h&gt;<br></div><div dir="ltr">+__RCSID("$NetBSD: gets_chk.c,v 1.7 2013/10/04 20:49:16 christos Exp $");<br></div><div dir="ltr">+<br></div><div dir="ltr">+#include &lt;limits.h&gt;<br></div><div dir="ltr">+#include &lt;stdio.h&gt;<br></div><div dir="ltr">+#include &lt;stdlib.h&gt;<br></div><div dir="ltr">+#include &lt;string.h&gt;<br></div><div dir="ltr">+<br></div><div dir="ltr">+#include &lt;ssp/stdio.h&gt;<br></div><div dir="ltr">+#include &lt;ssp/string.h&gt;<br></div><div dir="ltr">+<br></div><div dir="ltr">+char *__gets_unsafe(char *);<br></div><div dir="ltr">+<br></div><div dir="ltr">+char *<br></div><div dir="ltr">+__gets_chk(char * __restrict buf, size_t slen)<br></div><div dir="ltr">+{<!-- --><br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; char *abuf;<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; size_t len;<br></div><div dir="ltr">+<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; if (slen &gt;= (size_t)INT_MAX)<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return (__gets_unsafe(buf));<br></div><div dir="ltr">+<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; if ((abuf = malloc(slen + 1)) == NULL)<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return (__gets_unsafe(buf));<br></div><div dir="ltr">+<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; if (fgets(abuf, (int)(slen + 1), stdin) == NULL) {<!-- --><br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; free(abuf);<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return (NULL);<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; }<br></div><div dir="ltr">+<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; len = strlen(abuf);<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; if (len &gt; 0 &amp;&amp; abuf[len - 1] == '\n')<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; --len;<br></div><div dir="ltr">+<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; if (len &gt;= slen)<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; __chk_fail();<br></div><div dir="ltr">+<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; (void)memcpy(buf, abuf, len);<br></div><div dir="ltr">+<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; buf[len] = '\0';<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; free(abuf);<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; return (buf);<br></div><div dir="ltr">+}<br></div><div dir="ltr">diff --git a/lib/libc/secure/memcpy_chk.c b/lib/libc/secure/memcpy_chk.c<br></div><div dir="ltr">new file mode 100644<br></div><div dir="ltr">index 000000000000..99cf2d5f13ff<br></div><div dir="ltr">--- /dev/null<br></div><div dir="ltr">+++ b/lib/libc/secure/memcpy_chk.c<br></div><div dir="ltr">@@ -0,0 +1,53 @@<br></div><div dir="ltr">+/*-<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * SPDX-License-Identifier: BSD-2-Clause<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * Copyright (c) 2006 The NetBSD Foundation, Inc.<br></div><div dir="ltr">+ * All rights reserved.<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * This code is derived from software contributed to The NetBSD Foundation<br></div><div dir="ltr">+ * by Christos Zoulas.<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * Redistribution and use in source and binary forms, with or without<br></div><div dir="ltr">+ * modification, are permitted provided that the following conditions<br></div><div dir="ltr">+ * are met:<br></div><div dir="ltr">+ * 1. Redistributions of source code must retain the above copyright<br></div><div dir="ltr">+ *&nbsp; &nbsp; notice, this list of conditions and the following disclaimer.<br></div><div dir="ltr">+ * 2. Redistributions in binary form must reproduce the above copyright<br></div><div dir="ltr">+ *&nbsp; &nbsp; notice, this list of conditions and the following disclaimer in the<br></div><div dir="ltr">+ *&nbsp; &nbsp; documentation and/or other materials provided with the distribution.<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS<br></div><div dir="ltr">+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED<br></div><div dir="ltr">+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR<br></div><div dir="ltr">+ * PURPOSE ARE DISCLAIMED.&nbsp; IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS<br></div><div dir="ltr">+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR<br></div><div dir="ltr">+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF<br></div><div dir="ltr">+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS<br></div><div dir="ltr">+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN<br></div><div dir="ltr">+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)<br></div><div dir="ltr">+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE<br></div><div dir="ltr">+ * POSSIBILITY OF SUCH DAMAGE.<br></div><div dir="ltr">+ */<br></div><div dir="ltr">+#include &lt;sys/cdefs.h&gt;<br></div><div dir="ltr">+__RCSID("$NetBSD: memcpy_chk.c,v 1.7 2015/05/13 19:57:16 joerg Exp $");<br></div><div dir="ltr">+<br></div><div dir="ltr">+#include &lt;string.h&gt;<br></div><div dir="ltr">+<br></div><div dir="ltr">+#include &lt;ssp/string.h&gt;<br></div><div dir="ltr">+#undef memcpy<br></div><div dir="ltr">+<br></div><div dir="ltr">+#include "ssp_internal.h"<br></div><div dir="ltr">+<br></div><div dir="ltr">+void *<br></div><div dir="ltr">+__memcpy_chk(void * __restrict dst, const void * __restrict src, size_t len,<br></div><div dir="ltr">+&nbsp; &nbsp; size_t slen)<br></div><div dir="ltr">+{<!-- --><br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; if (len &gt; slen)<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; __chk_fail();<br></div><div dir="ltr">+<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; if (__ssp_overlap((const char *)src, (const char *)dst, len))<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; __chk_fail();<br></div><div dir="ltr">+<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; return (memcpy(dst, src, len));<br></div><div dir="ltr">+}<br></div><div dir="ltr">diff --git a/lib/libc/secure/memmove_chk.c b/lib/libc/secure/memmove_chk.c<br></div><div dir="ltr">new file mode 100644<br></div><div dir="ltr">index 000000000000..07f965d608fc<br></div><div dir="ltr">--- /dev/null<br></div><div dir="ltr">+++ b/lib/libc/secure/memmove_chk.c<br></div><div dir="ltr">@@ -0,0 +1,47 @@<br></div><div dir="ltr">+/*-<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * SPDX-License-Identifier: BSD-2-Clause<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * Copyright (c) 2006 The NetBSD Foundation, Inc.<br></div><div dir="ltr">+ * All rights reserved.<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * This code is derived from software contributed to The NetBSD Foundation<br></div><div dir="ltr">+ * by Christos Zoulas.<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * Redistribution and use in source and binary forms, with or without<br></div><div dir="ltr">+ * modification, are permitted provided that the following conditions<br></div><div dir="ltr">+ * are met:<br></div><div dir="ltr">+ * 1. Redistributions of source code must retain the above copyright<br></div><div dir="ltr">+ *&nbsp; &nbsp; notice, this list of conditions and the following disclaimer.<br></div><div dir="ltr">+ * 2. Redistributions in binary form must reproduce the above copyright<br></div><div dir="ltr">+ *&nbsp; &nbsp; notice, this list of conditions and the following disclaimer in the<br></div><div dir="ltr">+ *&nbsp; &nbsp; documentation and/or other materials provided with the distribution.<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS<br></div><div dir="ltr">+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED<br></div><div dir="ltr">+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR<br></div><div dir="ltr">+ * PURPOSE ARE DISCLAIMED.&nbsp; IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS<br></div><div dir="ltr">+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR<br></div><div dir="ltr">+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF<br></div><div dir="ltr">+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS<br></div><div dir="ltr">+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN<br></div><div dir="ltr">+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)<br></div><div dir="ltr">+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE<br></div><div dir="ltr">+ * POSSIBILITY OF SUCH DAMAGE.<br></div><div dir="ltr">+ */<br></div><div dir="ltr">+#include &lt;sys/cdefs.h&gt;<br></div><div dir="ltr">+__RCSID("$NetBSD: memmove_chk.c,v 1.6 2020/09/05 13:37:59 mrg Exp $");<br></div><div dir="ltr">+<br></div><div dir="ltr">+#include &lt;string.h&gt;<br></div><div dir="ltr">+<br></div><div dir="ltr">+#include &lt;ssp/string.h&gt;<br></div><div dir="ltr">+#undef memmove<br></div><div dir="ltr">+<br></div><div dir="ltr">+void *<br></div><div dir="ltr">+__memmove_chk(void *dst, const void *src, size_t len,<br></div><div dir="ltr">+&nbsp; &nbsp; size_t slen)<br></div><div dir="ltr">+{<!-- --><br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; if (len &gt; slen)<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; __chk_fail();<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; return (memmove(dst, src, len));<br></div><div dir="ltr">+}<br></div><div dir="ltr">diff --git a/lib/libc/secure/memset_chk.c b/lib/libc/secure/memset_chk.c<br></div><div dir="ltr">new file mode 100644<br></div><div dir="ltr">index 000000000000..f337be98b46d<br></div><div dir="ltr">--- /dev/null<br></div><div dir="ltr">+++ b/lib/libc/secure/memset_chk.c<br></div><div dir="ltr">@@ -0,0 +1,46 @@<br></div><div dir="ltr">+/*-<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * SPDX-License-Identifier: BSD-2-Clause<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * Copyright (c) 2006 The NetBSD Foundation, Inc.<br></div><div dir="ltr">+ * All rights reserved.<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * This code is derived from software contributed to The NetBSD Foundation<br></div><div dir="ltr">+ * by Christos Zoulas.<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * Redistribution and use in source and binary forms, with or without<br></div><div dir="ltr">+ * modification, are permitted provided that the following conditions<br></div><div dir="ltr">+ * are met:<br></div><div dir="ltr">+ * 1. Redistributions of source code must retain the above copyright<br></div><div dir="ltr">+ *&nbsp; &nbsp; notice, this list of conditions and the following disclaimer.<br></div><div dir="ltr">+ * 2. Redistributions in binary form must reproduce the above copyright<br></div><div dir="ltr">+ *&nbsp; &nbsp; notice, this list of conditions and the following disclaimer in the<br></div><div dir="ltr">+ *&nbsp; &nbsp; documentation and/or other materials provided with the distribution.<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS<br></div><div dir="ltr">+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED<br></div><div dir="ltr">+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR<br></div><div dir="ltr">+ * PURPOSE ARE DISCLAIMED.&nbsp; IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS<br></div><div dir="ltr">+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR<br></div><div dir="ltr">+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF<br></div><div dir="ltr">+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS<br></div><div dir="ltr">+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN<br></div><div dir="ltr">+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)<br></div><div dir="ltr">+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE<br></div><div dir="ltr">+ * POSSIBILITY OF SUCH DAMAGE.<br></div><div dir="ltr">+ */<br></div><div dir="ltr">+#include &lt;sys/cdefs.h&gt;<br></div><div dir="ltr">+__RCSID("$NetBSD: memset_chk.c,v 1.5 2014/09/17 00:39:28 joerg Exp $");<br></div><div dir="ltr">+<br></div><div dir="ltr">+#include &lt;string.h&gt;<br></div><div dir="ltr">+<br></div><div dir="ltr">+#include &lt;ssp/string.h&gt;<br></div><div dir="ltr">+#undef memset<br></div><div dir="ltr">+<br></div><div dir="ltr">+void *<br></div><div dir="ltr">+__memset_chk(void * __restrict dst, int val, size_t len, size_t slen)<br></div><div dir="ltr">+{<!-- --><br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; if (len &gt; slen)<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; __chk_fail();<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; return (memset(dst, val, len));<br></div><div dir="ltr">+}<br></div><div dir="ltr">diff --git a/lib/libc/secure/snprintf_chk.c b/lib/libc/secure/snprintf_chk.c<br></div><div dir="ltr">new file mode 100644<br></div><div dir="ltr">index 000000000000..52ef874ede5b<br></div><div dir="ltr">--- /dev/null<br></div><div dir="ltr">+++ b/lib/libc/secure/snprintf_chk.c<br></div><div dir="ltr">@@ -0,0 +1,56 @@<br></div><div dir="ltr">+/*-<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * SPDX-License-Identifier: BSD-2-Clause<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * Copyright (c) 2006 The NetBSD Foundation, Inc.<br></div><div dir="ltr">+ * All rights reserved.<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * This code is derived from software contributed to The NetBSD Foundation<br></div><div dir="ltr">+ * by Christos Zoulas.<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * Redistribution and use in source and binary forms, with or without<br></div><div dir="ltr">+ * modification, are permitted provided that the following conditions<br></div><div dir="ltr">+ * are met:<br></div><div dir="ltr">+ * 1. Redistributions of source code must retain the above copyright<br></div><div dir="ltr">+ *&nbsp; &nbsp; notice, this list of conditions and the following disclaimer.<br></div><div dir="ltr">+ * 2. Redistributions in binary form must reproduce the above copyright<br></div><div dir="ltr">+ *&nbsp; &nbsp; notice, this list of conditions and the following disclaimer in the<br></div><div dir="ltr">+ *&nbsp; &nbsp; documentation and/or other materials provided with the distribution.<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS<br></div><div dir="ltr">+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED<br></div><div dir="ltr">+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR<br></div><div dir="ltr">+ * PURPOSE ARE DISCLAIMED.&nbsp; IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS<br></div><div dir="ltr">+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR<br></div><div dir="ltr">+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF<br></div><div dir="ltr">+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS<br></div><div dir="ltr">+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN<br></div><div dir="ltr">+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)<br></div><div dir="ltr">+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE<br></div><div dir="ltr">+ * POSSIBILITY OF SUCH DAMAGE.<br></div><div dir="ltr">+ */<br></div><div dir="ltr">+#include &lt;sys/cdefs.h&gt;<br></div><div dir="ltr">+__RCSID("$NetBSD: snprintf_chk.c,v 1.5 2008/04/28 20:23:00 martin Exp $");<br></div><div dir="ltr">+<br></div><div dir="ltr">+#include &lt;stdarg.h&gt;<br></div><div dir="ltr">+#include &lt;stdio.h&gt;<br></div><div dir="ltr">+<br></div><div dir="ltr">+#include &lt;ssp/stdio.h&gt;<br></div><div dir="ltr">+#undef vsnprintf<br></div><div dir="ltr">+<br></div><div dir="ltr">+int<br></div><div dir="ltr">+__snprintf_chk(char * __restrict buf, size_t len, int flags, size_t slen,<br></div><div dir="ltr">+&nbsp; &nbsp; const char * __restrict fmt, ...)<br></div><div dir="ltr">+{<!-- --><br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; va_list ap;<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; int rv;<br></div><div dir="ltr">+<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; if (len &gt; slen)<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; __chk_fail();<br></div><div dir="ltr">+<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; va_start(ap, fmt);<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; rv = vsnprintf(buf, len, fmt, ap);<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; va_end(ap);<br></div><div dir="ltr">+<br></div><div dir="ltr">+&nbsp;&nbsp;&nbsp; return (rv);<br></div><div dir="ltr">+}<br></div><div dir="ltr">diff --git a/lib/libc/secure/sprintf_chk.c b/lib/libc/secure/sprintf_chk.c<br></div><div dir="ltr">new file mode 100644<br></div><div dir="ltr">index 000000000000..d4c42ccba3ce<br></div><div dir="ltr">--- /dev/null<br></div><div dir="ltr">+++ b/lib/libc/secure/sprintf_chk.c<br></div><div dir="ltr">@@ -0,0 +1,61 @@<br></div><div dir="ltr">+/*-<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * SPDX-License-Identifier: BSD-2-Clause<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * Copyright (c) 2006 The NetBSD Foundation, Inc.<br></div><div dir="ltr">+ * All rights reserved.<br></div><div dir="ltr">+ *<br></div><div dir="ltr">+ * This code is derived from software contributed to The NetBSD Foundation<br></div><div dir="ltr">*** 1063 LINES SKIPPED ***<br></div></div>
            </div>
        </div></div></blockquote></div><br></div></div></div>