aboutsummaryrefslogtreecommitdiffstats
path: root/debug/vswprintf_chk.c
diff options
context:
space:
mode:
authorZack Weinberg <zackw@panix.com>2018-03-07 09:08:49 -0500
committerZack Weinberg <zackw@panix.com>2018-05-31 21:28:17 -0400
commit99dc7e331834f942d72c017782b8c058414cc70d (patch)
tree32dc4a6b39da3297e1f6a60f31c38f14fac92e73 /debug/vswprintf_chk.c
parent665a5665924b44f5de0938e4c1a077d5bcfee061 (diff)
downloadtermbaud-99dc7e331834f942d72c017782b8c058414cc70d.tar.gz
termbaud-99dc7e331834f942d72c017782b8c058414cc70d.tar.xz
termbaud-99dc7e331834f942d72c017782b8c058414cc70d.zip
Use PRINTF_LDBL_IS_DBL instead of __ldbl_is_dbl.zack/remove-mode-bits
After all that prep work, nldbl-compat.c can now use PRINTF_LDBL_IS_DBL instead of __no_long_double to control the behavior of printf-like functions; this is the last thing we needed __no_long_double for, so it can go away entirely. * stdio-common/vfprintf-internal.c (__vfprintf_internal, __vfwprintf_internal): Don't use __ldbl_is_dbl. * sysdeps/generic/math_ldbl_opt.h: Remove __ldbl_is_dbl. * sysdeps/ieee754/ldbl-opt/math_ldbl_opt.h: Remove __ldbl_is_dbl and __no_long_double. * sysdeps/ieee754/ldbl-opt/math_ldbl_opt.c: Remove file. * sysdeps/ieee754/ldbl-opt/Makefile (routines): Remove math_ldbl_opt. * sysdeps/ieee754/ldbl-opt/nldbl-compat.c (__nldbl_cleanup, set_no_long_double, clear_no_long_double): Remove. (__nldbl___asprintf, __nldbl_dprintf, __nldbl_fprintf) (__nldbl_fwprintf, __nldbl_printf, __nldbl_sprintf) (__nldbl_vfprintf, __nldbl___vsprintf, __nldbl_obstack_vprintf) (__ndlbl_obstack_printf, __nldbl_snprintf, __nldbl_swprintf) (__nldbl_vasprintf, __nldbl_vdprintf, __nldbl_vfwprintf) (__nldbl_vprintf, __nldbl_vsnprintf, __ndlbl_vswprintf) (__nldbl_vwprintf, __nldbl_wprintf): Directly call the appropriate __v*printf_internal routine, passing PRINTF_LDBL_IS_DBL. Do not mess with __no_long_double. Normalize variable names. (__nldbl___fprintf_chk, __nldbl___fwprintf_chk) (__nldbl___printf_chk, __nldbl___snprintf_chk) (__nldbl___sprintf_chk, __nldbl___swprintf_chk) (__nldbl___vfprintf_chk, __nldbl___vfwprintf_chk) (__nldbl___vprintf_chk, __nldbl___vsnprintf_chk) (__nldbl___vsprintf_chk, __nldbl___vswprintf_chk) (__nldbl___vwprintf_chk, __nldbl___wprintf_chk) (__nldbl___vasprintf_chk, __nldbl___asprintf_chk) (__nldbl___vdprintf_chk, __nldbl___dprintf_chk) (__nldbl___obstack_vprintf_chk, __nldbl___obstack_printf_chk): Likewise, and also pass PRINTF_FORTIFY when appropriate. (__nldbl_syslog, __nldbl_vsyslog): Directly call __vsyslog_internal, passing PRINTF_LDBL_IS_DBL. (__nldbl_syslog_chk): Likewise, and also pass PRINTF_FORTIFY when appropriate. (__nldbl_vsyslog_chk): Likewise, and also pass PRINTF_FORTIFY when appropriate. Remove libc_hidden_proto and libc_hidden_def.
Diffstat (limited to 'debug/vswprintf_chk.c')
-rw-r--r--debug/vswprintf_chk.c51
1 files changed, 6 insertions, 45 deletions
diff --git a/debug/vswprintf_chk.c b/debug/vswprintf_chk.c
index 4d616f88354..2c6fadd4635 100644
--- a/debug/vswprintf_chk.c
+++ b/debug/vswprintf_chk.c
@@ -15,60 +15,21 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
-#include <stdarg.h>
-#include <wchar.h>
-#include "../libio/libioP.h"
-#include "../libio/strfile.h"
+#include <libio/libioP.h>
/* Write formatted output into S, according to the format
string FORMAT, writing no more than MAXLEN characters. */
-/* VARARGS5 */
int
-__vswprintf_chk (wchar_t *s, size_t maxlen, int flags, size_t slen,
- const wchar_t *format, va_list args)
+__vswprintf_chk (wchar_t *s, size_t maxlen, int flag, size_t slen,
+ const wchar_t *format, va_list ap)
{
- /* XXX Maybe for less strict version do not fail immediately.
- Though, maxlen is supposed to be the size of buffer pointed
- to by s, so a conforming program can't pass such maxlen
- to *snprintf. */
if (__glibc_unlikely (slen < maxlen))
__chk_fail ();
- _IO_wstrnfile sf;
- struct _IO_wide_data wd;
- int ret;
-#ifdef _IO_MTSAFE_IO
- sf.f._sbf._f._lock = NULL;
-#endif
-
- /* We need to handle the special case where MAXLEN is 0. Use the
- overflow buffer right from the start. */
- if (__glibc_unlikely (maxlen == 0))
- /* Since we have to write at least the terminating L'\0' a buffer
- length of zero always makes the function fail. */
- return -1;
-
- _IO_no_init (&sf.f._sbf._f, _IO_USER_LOCK, 0, &wd, &_IO_wstrn_jumps);
- _IO_fwide (&sf.f._sbf._f, 1);
- s[0] = L'\0';
-
- /* For flags > 0 (i.e. __USE_FORTIFY_LEVEL > 1) request that %n
+ /* For flag > 0 (i.e. __USE_FORTIFY_LEVEL > 1) request that %n
can only come from read-only format strings. */
- if (flags > 0)
- sf.f._sbf._f._flags2 |= _IO_FLAGS2_FORTIFY;
-
- _IO_wstr_init_static (&sf.f._sbf._f, s, maxlen - 1, s);
- ret = __vfwprintf_internal ((FILE *) &sf.f._sbf, format, args, 0);
-
- if (sf.f._sbf._f._wide_data->_IO_buf_base == sf.overflow_buf)
- /* ISO C99 requires swprintf/vswprintf to return an error if the
- output does not fit int he provided buffer. */
- return -1;
-
- /* Terminate the string. */
- *sf.f._sbf._f._wide_data->_IO_write_ptr = '\0';
+ unsigned int mode = (flag > 0) ? PRINTF_FORTIFY : 0;
- return ret;
+ return __vswprintf_internal (s, maxlen, format, ap, mode);
}
-libc_hidden_def (__vswprintf_chk)