1*404b540aSrobert /* Checking vsnprintf.
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 #include <stdarg.h>
39*404b540aSrobert #ifdef HAVE_STDIO_H
40*404b540aSrobert # include <stdio.h>
41*404b540aSrobert #endif
42*404b540aSrobert
43*404b540aSrobert extern void __chk_fail (void) __attribute__((__noreturn__));
44*404b540aSrobert
45*404b540aSrobert #ifdef HAVE_USABLE_VSNPRINTF
46*404b540aSrobert int
__vsnprintf_chk(char * s,size_t n,int flags,size_t slen,const char * format,va_list arg)47*404b540aSrobert __vsnprintf_chk (char *s, size_t n, int flags __attribute__((unused)),
48*404b540aSrobert size_t slen, const char *format, va_list arg)
49*404b540aSrobert {
50*404b540aSrobert if (n > slen)
51*404b540aSrobert __chk_fail ();
52*404b540aSrobert
53*404b540aSrobert return vsnprintf (s, n, format, arg);
54*404b540aSrobert }
55*404b540aSrobert #endif
56