xref: /openbsd-src/gnu/gcc/libssp/memset-chk.c (revision 404b540a9034ac75a6199ad1a32d1bbc7a0d4210)
1*404b540aSrobert /* Checking memset.
2*404b540aSrobert    Copyright (C) 2005 Free Software Foundation, Inc.
3*404b540aSrobert 
4*404b540aSrobert This file is part of GCC.
5*404b540aSrobert 
6*404b540aSrobert GCC is free software; you can redistribute it and/or modify it under
7*404b540aSrobert the terms of the GNU General Public License as published by the Free
8*404b540aSrobert Software Foundation; either version 2, or (at your option) any later
9*404b540aSrobert version.
10*404b540aSrobert 
11*404b540aSrobert In addition to the permissions in the GNU General Public License, the
12*404b540aSrobert Free Software Foundation gives you unlimited permission to link the
13*404b540aSrobert compiled version of this file into combinations with other programs,
14*404b540aSrobert and to distribute those combinations without any restriction coming
15*404b540aSrobert from the use of this file.  (The General Public License restrictions
16*404b540aSrobert do apply in other respects; for example, they cover modification of
17*404b540aSrobert the file, and distribution when not linked into a combine
18*404b540aSrobert executable.)
19*404b540aSrobert 
20*404b540aSrobert GCC is distributed in the hope that it will be useful, but WITHOUT ANY
21*404b540aSrobert WARRANTY; without even the implied warranty of MERCHANTABILITY or
22*404b540aSrobert FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
23*404b540aSrobert for more details.
24*404b540aSrobert 
25*404b540aSrobert You should have received a copy of the GNU General Public License
26*404b540aSrobert along with GCC; see the file COPYING.  If not, write to the Free
27*404b540aSrobert Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
28*404b540aSrobert 02110-1301, USA.  */
29*404b540aSrobert 
30*404b540aSrobert /* As a special exception, if you link this library with files compiled with
31*404b540aSrobert    GCC to produce an executable, this does not cause the resulting executable
32*404b540aSrobert    to be covered by the GNU General Public License. This exception does not
33*404b540aSrobert    however invalidate any other reasons why the executable file might be
34*404b540aSrobert    covered by the GNU General Public License.  */
35*404b540aSrobert 
36*404b540aSrobert #include "config.h"
37*404b540aSrobert #include <ssp/ssp.h>
38*404b540aSrobert #ifdef HAVE_STRING_H
39*404b540aSrobert # include <string.h>
40*404b540aSrobert #endif
41*404b540aSrobert 
42*404b540aSrobert extern void __chk_fail (void) __attribute__((__noreturn__));
43*404b540aSrobert 
44*404b540aSrobert void *
__memset_chk(void * dest,int val,size_t len,size_t slen)45*404b540aSrobert __memset_chk (void *dest, int val, size_t len, size_t slen)
46*404b540aSrobert {
47*404b540aSrobert   if (len > slen)
48*404b540aSrobert     __chk_fail ();
49*404b540aSrobert   return memset (dest, val, len);
50*404b540aSrobert }
51