1116744Ssam/* Checking strncpy. 2185522Ssam Copyright (C) 2005, 2009 Free Software Foundation, Inc. 3116744Ssam 4116744SsamThis file is part of GCC. 5116744Ssam 6116744SsamGCC is free software; you can redistribute it and/or modify it under 7116744Ssamthe terms of the GNU General Public License as published by the Free 8116744SsamSoftware Foundation; either version 3, or (at your option) any later 9116744Ssamversion. 10116744Ssam 11116744SsamIn addition to the permissions in the GNU General Public License, the 12116744SsamFree Software Foundation gives you unlimited permission to link the 13116744Ssamcompiled version of this file into combinations with other programs, 14116744Ssamand to distribute those combinations without any restriction coming 15116744Ssamfrom the use of this file. (The General Public License restrictions 16116744Ssamdo apply in other respects; for example, they cover modification of 17116744Ssamthe file, and distribution when not linked into a combine 18116744Ssamexecutable.) 19116744Ssam 20116744SsamGCC is distributed in the hope that it will be useful, but WITHOUT ANY 21116744SsamWARRANTY; without even the implied warranty of MERCHANTABILITY or 22116744SsamFITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 23116744Ssamfor more details. 24116744Ssam 25116744SsamUnder Section 7 of GPL version 3, you are granted additional 26116744Ssampermissions described in the GCC Runtime Library Exception, version 27116744Ssam3.1, as published by the Free Software Foundation. 28116744Ssam 29116744SsamYou should have received a copy of the GNU General Public License and 30116744Ssama copy of the GCC Runtime Library Exception along with this program; 31116744Ssamsee the files COPYING3 and COPYING.RUNTIME respectively. If not, see 32186094Ssam<http://www.gnu.org/licenses/>. */ 33116744Ssam 34186094Ssam#include "config.h" 35186094Ssam#include <ssp/ssp.h> 36186094Ssam#ifdef HAVE_STRING_H 37186094Ssam# include <string.h> 38220185Sadrian#endif 39235679Sadrian 40186094Ssamextern void __chk_fail (void) __attribute__((__noreturn__)); 41203286Srpaulo 42190571Ssam#ifdef HAVE_STRNCPY 43186094Ssamchar * 44186094Ssam__strncpy_chk (char *__restrict__ dest, const char *__restrict__ src, 45186094Ssam size_t len, size_t slen) 46186094Ssam{ 47186094Ssam if (len > slen) 48186094Ssam __chk_fail (); 49185522Ssam return strncpy (dest, src, len); 50185522Ssam} 51185522Ssam#endif 52186094Ssam