diff options
author | Jakub Jelinek <jakub@redhat.com> | 2004-10-18 09:58:59 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2004-10-18 09:58:59 +0000 |
commit | 56c4396a6e1568a5511ac43873fa3c9e1ebfa8d1 (patch) | |
tree | f2d0f6e1aaf9794668b53c6456fcacbbacd63805 /libio | |
parent | 4ce1a5c9712b4d7616058e708630c33744f983f6 (diff) | |
download | glibc-56c4396a6e1568a5511ac43873fa3c9e1ebfa8d1.tar.gz |
Updated to fedora-glibc-20041018T0940
Diffstat (limited to 'libio')
-rw-r--r-- | libio/Makefile | 4 | ||||
-rw-r--r-- | libio/bits/stdio2.h | 78 | ||||
-rw-r--r-- | libio/libio.h | 3 | ||||
-rw-r--r-- | libio/stdio.h | 3 | ||||
-rw-r--r-- | libio/strfile.h | 10 | ||||
-rw-r--r-- | libio/vsnprintf.c | 12 | ||||
-rw-r--r-- | libio/vswprintf.c | 8 |
7 files changed, 101 insertions, 17 deletions
diff --git a/libio/Makefile b/libio/Makefile index c7253ff571..a9384b55a9 100644 --- a/libio/Makefile +++ b/libio/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 1995-2002, 2003 Free Software Foundation, Inc. +# Copyright (C) 1995-2002, 2003, 2004 Free Software Foundation, Inc. # This file is part of the GNU C Library. # The GNU C Library is free software; you can redistribute it and/or @@ -22,7 +22,7 @@ subdir := libio headers := stdio.h libio.h _G_config.h bits/stdio.h bits/stdio-lock.h \ - bits/sys_errlist.h + bits/sys_errlist.h bits/stdio2.h routines := \ filedoalloc iofclose iofdopen iofflush iofgetpos iofgets iofopen \ diff --git a/libio/bits/stdio2.h b/libio/bits/stdio2.h new file mode 100644 index 0000000000..acf07ea91b --- /dev/null +++ b/libio/bits/stdio2.h @@ -0,0 +1,78 @@ +/* Checking macros for stdio functions. + Copyright (C) 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _STDIO_H +# error "Never include <bits/stdio2.h> directly; use <stdio.h> instead." +#endif + +extern int __sprintf_chk (char *__restrict __s, int __flag, size_t __slen, + __const char *__restrict __format, ...) __THROW; +extern int __vsprintf_chk (char *__restrict __s, int __flag, size_t __slen, + __const char *__restrict __format, + _G_va_list __ap) __THROW; + +#define sprintf(str, ...) \ + __builtin___sprintf_chk (str, __USE_FORTIFY_LEVEL - 1, __bos (str), \ + __VA_ARGS__) +#define vsprintf(str, fmt, ap) \ + __builtin___vsprintf_chk (str, __USE_FORTIFY_LEVEL - 1, __bos (str), fmt, ap) + +#if defined __USE_BSD || defined __USE_ISOC99 || defined __USE_UNIX98 + +extern int __snprintf_chk (char *__restrict __s, size_t __n, int __flag, + size_t __slen, __const char *__restrict __format, + ...) __THROW; +extern int __vsnprintf_chk (char *__restrict __s, size_t __n, int __flag, + size_t __slen, __const char *__restrict __format, + _G_va_list __ap) __THROW; + +# define snprintf(str, len, ...) \ + __builtin___snprintf_chk (str, len, __USE_FORTIFY_LEVEL - 1, __bos (str), \ + __VA_ARGS__) +# define vsnprintf(str, len, fmt, ap) \ + __builtin___vsnprintf_chk (str, len, __USE_FORTIFY_LEVEL - 1, __bos (str), \ + fmt, ap) + +#endif + +#if __USE_FORTIFY_LEVEL > 1 + +extern int __fprintf_chk (FILE *__restrict __stream, int __flag, + __const char *__restrict __format, ...); +extern int __printf_chk (int __flag, __const char *__restrict __format, ...); +extern int __vfprintf_chk (FILE *__restrict __stream, int __flag, + __const char *__restrict __format, _G_va_list __ap); +extern int __vprintf_chk (int __flag, __const char *__restrict __format, + _G_va_list __ap); + +# define printf(...) \ + __printf_chk (__USE_FORTIFY_LEVEL - 1, __VA_ARGS__) +# define fprintf(stream, ...) \ + __fprintf_chk (stream, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__) +# define vprintf(format, ap) \ + __vprintf_chk (__USE_FORTIFY_LEVEL - 1, format, ap) +# define vfprintf(stream, format, ap) \ + __vfprintf_chk (stream, __USE_FORTIFY_LEVEL - 1, format, ap) + +#endif + +extern char *__gets_chk (char *__str, size_t); +#define gets(__str) \ + ((__bos (__str) == (size_t) -1) \ + ? (gets) (__str) : __gets_chk (__str, __bos (__str))) diff --git a/libio/libio.h b/libio/libio.h index 1672f7b54f..645f9fb83c 100644 --- a/libio/libio.h +++ b/libio/libio.h @@ -139,6 +139,9 @@ #define _IO_FLAGS2_MMAP 1 #define _IO_FLAGS2_NOTCANCEL 2 +#ifdef _LIBC +# define _IO_FLAGS2_CHECK_PERCENT_N 4 +#endif /* These are "formatting flags" matching the iostream fmtflags enum values. */ #define _IO_SKIPWS 01 diff --git a/libio/stdio.h b/libio/stdio.h index 385bc64618..941a2afc74 100644 --- a/libio/stdio.h +++ b/libio/stdio.h @@ -829,6 +829,9 @@ extern void funlockfile (FILE *__stream) __THROW; #ifdef __USE_EXTERN_INLINES # include <bits/stdio.h> #endif +#if __USE_FORTIFY_LEVEL > 0 && !defined __cplusplus +# include <bits/stdio2.h> +#endif __END_DECLS diff --git a/libio/strfile.h b/libio/strfile.h index bcac784717..b91111a9d6 100644 --- a/libio/strfile.h +++ b/libio/strfile.h @@ -63,3 +63,13 @@ typedef struct _IO_strfile_ /* frozen: set when the program has requested that the array object not be altered, reallocated, or freed. */ #define _IO_STR_FROZEN(FP) ((FP)->_f._IO_file_flags & _IO_USER_BUF) + +typedef struct +{ + _IO_strfile f; + /* This is used for the characters which do not fit in the buffer + provided by the user. */ + char overflow_buf[64]; +} _IO_strnfile; + +extern const struct _IO_jump_t _IO_strn_jumps attribute_hidden; diff --git a/libio/vsnprintf.c b/libio/vsnprintf.c index e2cfb16d8a..4250c2d2de 100644 --- a/libio/vsnprintf.c +++ b/libio/vsnprintf.c @@ -28,16 +28,6 @@ #include "libioP.h" #include "strfile.h" - -typedef struct -{ - _IO_strfile f; - /* This is used for the characters which do not fit in the buffer - provided by the user. */ - char overflow_buf[64]; -} _IO_strnfile; - - static int _IO_strn_overflow (_IO_FILE *fp, int c) __THROW; static int @@ -77,7 +67,7 @@ _IO_strn_overflow (fp, c) } -static const struct _IO_jump_t _IO_strn_jumps = +const struct _IO_jump_t _IO_strn_jumps attribute_hidden = { JUMP_INIT_DUMMY, JUMP_INIT(finish, _IO_str_finish), diff --git a/libio/vswprintf.c b/libio/vswprintf.c index 3cf01e2c84..42168aade4 100644 --- a/libio/vswprintf.c +++ b/libio/vswprintf.c @@ -35,7 +35,7 @@ typedef struct /* This is used for the characters which do not fit in the buffer provided by the user. */ wchar_t overflow_buf[64]; -} _IO_strnfile; +} _IO_wstrnfile; static wint_t _IO_wstrn_overflow (_IO_FILE *fp, wint_t c) __THROW; @@ -49,8 +49,8 @@ _IO_wstrn_overflow (fp, c) filled. But since we must return the number of characters which would have been written in total we must provide a buffer for further use. We can do this by writing on and on in the overflow - buffer in the _IO_strnfile structure. */ - _IO_strnfile *snf = (_IO_strnfile *) fp; + buffer in the _IO_wstrnfile structure. */ + _IO_wstrnfile *snf = (_IO_wstrnfile *) fp; if (fp->_wide_data->_IO_buf_base != snf->overflow_buf) { @@ -107,7 +107,7 @@ _IO_vswprintf (string, maxlen, format, args) const wchar_t *format; _IO_va_list args; { - _IO_strnfile sf; + _IO_wstrnfile sf; int ret; struct _IO_wide_data wd; #ifdef _IO_MTSAFE_IO |