aboutsummaryrefslogtreecommitdiff
path: root/stdio-common/vfprintf.c
AgeCommit message (Collapse)AuthorFilesLines
2018-01-01Update copyright dates with scripts/update-copyrights.Joseph Myers1-1/+1
* All files with FSF copyright notices: Update copyright dates using scripts/update-copyrights. * locale/programs/charmap-kw.h: Regenerated. * locale/programs/locfile-kw.h: Likewise.
2017-11-02stdio-common: Use array_length and array_end macrosFlorian Weimer1-3/+3
2017-08-31stdio-common: Remove internal_function attributeFlorian Weimer1-2/+1
2017-06-29vfprintf: Reuse work_buffer in group_numberFlorian Weimer1-29/+38
2017-06-29vfprintf: Use struct scratch_buffer for positional arguments allocationFlorian Weimer1-40/+28
2017-06-29vfprintf: Reduce WORK_BUFFER_SIZE for wchar_t buildsFlorian Weimer1-1/+1
2017-06-07float128: Add strfromf128Gabriel F. T. Gomes1-2/+8
Add strfromf128 to stdlib when _Float128 support is enabled. * stdio-common/printf-parsemb.c (__parse_one_specmb): Initialize spec->info.is_binary128 to zero. * stdio-common/printf.h (printf_info): Add new member is_binary128 to indicate that the number being converted to string is compatible with the IEC 60559 binary128 format. * stdio-common/printf_fp.c (__printf_fp_l): Add code to deal with _Float128 numbers. * stdio-common/printf_fphex.c: Include ieee754_float128.h and ldbl-128/printf_fphex_macros.h (__printf_fphex): Add code to deal with _Float128 numbers. * stdio-common/printf_size.c (__printf_size): Likewise. * stdio-common/vfprintf.c (process_arg): Initialize member info.is_binary128 to zero. * stdlib/fpioconst.h (FLT128_MAX_10_EXP_LOG): New macro. * stdlib/stdlib.h: Include bits/floatn.h for _Float128 support. (strfromf128): New declaration. * stdlib/strfrom-skeleton.c (STRFROM): Set member info.is_binary128 to one. * sysdeps/ieee754/float128/Makefile: Add strfromf128. * sysdeps/ieee754/float128/Versions: Likewise. * sysdeps/ieee754/float128/strfromf128.c: New file.
2017-05-08vfprintf.c: Refactor magic number 32 into EXTSIZ.Carlos O'Donell1-25/+27
The magic number 32 is used everywhere as extra size to use when doing certain operations. This commit refactors that into a macro so you can change this value if you're debugging something in a local build.
2017-01-01Update copyright dates with scripts/update-copyrights.Joseph Myers1-1/+1
2016-09-02vfprintf: Avoid creating a VLA which complicates stack managementFlorian Weimer1-1/+1
2016-06-23libio: Implement vtable verification [BZ #20191]Florian Weimer1-2/+2
This commit puts all libio vtables in a dedicated, read-only ELF section, so that they are consecutive in memory. Before any indirect jump, the vtable pointer is checked against the section boundaries, and the process is terminated if the vtable pointer does not fall into the special ELF section. To enable backwards compatibility, a special flag variable (_IO_accept_foreign_vtables), protected by the pointer guard, avoids process termination if libio stream object constructor functions have been called earlier. Such constructor functions are called by the GCC 2.95 libstdc++ library, and this mechanism ensures compatibility with old binaries. Existing callers inside glibc of these functions are adjusted to call the original functions, not the wrappers which enable vtable compatiblity. The compatibility mechanism is used to enable passing FILE * objects across a static dlopen boundary, too.
2016-04-25vfprintf: Fix memory with large width and precision [BZ #19931]Florian Weimer1-0/+5
Free a previously allocated work buffer if it is not large enough.
2016-01-04Update copyright dates with scripts/update-copyrights.Joseph Myers1-1/+1
2015-10-17vfprintf: Rewrite printf_positional to use struct scratch_bufferFlorian Weimer1-40/+10
2015-09-16Fix BZ #18872 -- memory leak in printf_positional.Paul Pluzhnikov1-0/+4
2015-09-08Move bits/libc-lock.h and bits/libc-lockP.h out of bits/ (bug 14912).Joseph Myers1-1/+1
It was noted in <https://sourceware.org/ml/libc-alpha/2012-09/msg00305.html> that the bits/*.h naming scheme should only be used for installed headers. This patch renames bits/libc-lock.h to plain libc-lock.h and bits/libc-lockP.h to plain libc-lockP.h to follow that convention. Note that I don't know where libc-lockP.h comes from for Hurd (the Hurd libc-lock.h includes libc-lockP.h, but the only libc-lockP.h in the glibc source tree is for NPTL) - some unmerged patch? - but I updated the #include in the Hurd libc-lock.h anyway. Tested for x86_64 (testsuite, and that installed stripped shared libraries are unchanged by the patch). [BZ #14912] * bits/libc-lock.h: Move to ... * sysdeps/generic/libc-lock.h: ...here. (_BITS_LIBC_LOCK_H): Rename macro to _LIBC_LOCK_H. * sysdeps/mach/hurd/bits/libc-lock.h: Move to ... * sysdeps/mach/hurd/libc-lock.h: ...here. (_BITS_LIBC_LOCK_H): Rename macro to _LIBC_LOCK_H. [_LIBC]: Include <libc-lockP.h> instead of <bits/libc-lockP.h>. * sysdeps/mach/bits/libc-lock.h: Move to ... * sysdeps/mach/libc-lock.h: ...here. (_BITS_LIBC_LOCK_H): Rename macro to _LIBC_LOCK_H. * sysdeps/nptl/bits/libc-lock.h: Move to ... * sysdeps/nptl/libc-lock.h: ...here. (_BITS_LIBC_LOCK_H): Rename macro to _LIBC_LOCK_H. * sysdeps/nptl/bits/libc-lockP.h: Move to ... * sysdeps/nptl/libc-lockP.h: ...here. (_BITS_LIBC_LOCKP_H): Rename macro to _LIBC_LOCKP_H. * crypt/crypt_util.c: Include <libc-lock.h> instead of <bits/libc-lock.h>. * dirent/scandir-tail.c: Likewise. * dlfcn/dlerror.c: Likewise. * elf/dl-close.c: Likewise. * elf/dl-iteratephdr.c: Likewise. * elf/dl-lookup.c: Likewise. * elf/dl-open.c: Likewise. * elf/dl-support.c: Likewise. * elf/dl-writev.h: Likewise. * elf/rtld.c: Likewise. * grp/fgetgrent.c: Likewise. * gshadow/fgetsgent.c: Likewise. * gshadow/sgetsgent.c: Likewise. * iconv/gconv_conf.c: Likewise. * iconv/gconv_db.c: Likewise. * iconv/gconv_dl.c: Likewise. * iconv/gconv_int.h: Likewise. * iconv/gconv_trans.c: Likewise. * include/link.h: Likewise. * inet/getnameinfo.c: Likewise. * inet/getnetgrent.c: Likewise. * inet/getnetgrent_r.c: Likewise. * intl/bindtextdom.c: Likewise. * intl/dcigettext.c: Likewise. * intl/finddomain.c: Likewise. * intl/gettextP.h: Likewise. * intl/loadmsgcat.c: Likewise. * intl/localealias.c: Likewise. * intl/textdomain.c: Likewise. * libidn/idn-stub.c: Likewise. * libio/libioP.h: Likewise. * locale/duplocale.c: Likewise. * locale/freelocale.c: Likewise. * locale/newlocale.c: Likewise. * locale/setlocale.c: Likewise. * login/getutent_r.c: Likewise. * login/getutid_r.c: Likewise. * login/getutline_r.c: Likewise. * login/utmp-private.h: Likewise. * login/utmpname.c: Likewise. * malloc/mtrace.c: Likewise. * misc/efgcvt.c: Likewise. * misc/error.c: Likewise. * misc/fstab.c: Likewise. * misc/getpass.c: Likewise. * misc/mntent.c: Likewise. * misc/syslog.c: Likewise. * nis/nis_call.c: Likewise. * nis/nis_callback.c: Likewise. * nis/nss-default.c: Likewise. * nis/nss_compat/compat-grp.c: Likewise. * nis/nss_compat/compat-initgroups.c: Likewise. * nis/nss_compat/compat-pwd.c: Likewise. * nis/nss_compat/compat-spwd.c: Likewise. * nis/nss_nis/nis-alias.c: Likewise. * nis/nss_nis/nis-ethers.c: Likewise. * nis/nss_nis/nis-grp.c: Likewise. * nis/nss_nis/nis-hosts.c: Likewise. * nis/nss_nis/nis-network.c: Likewise. * nis/nss_nis/nis-proto.c: Likewise. * nis/nss_nis/nis-pwd.c: Likewise. * nis/nss_nis/nis-rpc.c: Likewise. * nis/nss_nis/nis-service.c: Likewise. * nis/nss_nis/nis-spwd.c: Likewise. * nis/nss_nisplus/nisplus-alias.c: Likewise. * nis/nss_nisplus/nisplus-ethers.c: Likewise. * nis/nss_nisplus/nisplus-grp.c: Likewise. * nis/nss_nisplus/nisplus-hosts.c: Likewise. * nis/nss_nisplus/nisplus-initgroups.c: Likewise. * nis/nss_nisplus/nisplus-network.c: Likewise. * nis/nss_nisplus/nisplus-proto.c: Likewise. * nis/nss_nisplus/nisplus-pwd.c: Likewise. * nis/nss_nisplus/nisplus-rpc.c: Likewise. * nis/nss_nisplus/nisplus-service.c: Likewise. * nis/nss_nisplus/nisplus-spwd.c: Likewise. * nis/ypclnt.c: Likewise. * nptl/libc_pthread_init.c: Likewise. * nss/getXXbyYY.c: Likewise. * nss/getXXent.c: Likewise. * nss/getXXent_r.c: Likewise. * nss/nss_db/db-XXX.c: Likewise. * nss/nss_db/db-netgrp.c: Likewise. * nss/nss_db/nss_db.h: Likewise. * nss/nss_files/files-XXX.c: Likewise. * nss/nss_files/files-alias.c: Likewise. * nss/nsswitch.c: Likewise. * posix/regex_internal.h: Likewise. * posix/wordexp.c: Likewise. * pwd/fgetpwent.c: Likewise. * resolv/res_hconf.c: Likewise. * resolv/res_libc.c: Likewise. * shadow/fgetspent.c: Likewise. * shadow/lckpwdf.c: Likewise. * shadow/sgetspent.c: Likewise. * socket/opensock.c: Likewise. * stdio-common/reg-modifier.c: Likewise. * stdio-common/reg-printf.c: Likewise. * stdio-common/reg-type.c: Likewise. * stdio-common/vfprintf.c: Likewise. * stdio-common/vfscanf.c: Likewise. * stdlib/abort.c: Likewise. * stdlib/cxa_atexit.c: Likewise. * stdlib/fmtmsg.c: Likewise. * stdlib/random.c: Likewise. * stdlib/setenv.c: Likewise. * string/strsignal.c: Likewise. * sunrpc/auth_none.c: Likewise. * sunrpc/bindrsvprt.c: Likewise. * sunrpc/create_xid.c: Likewise. * sunrpc/key_call.c: Likewise. * sunrpc/rpc_thread.c: Likewise. * sysdeps/arm/backtrace.c: Likewise. * sysdeps/generic/ldsodefs.h: Likewise. * sysdeps/generic/stdio-lock.h: Likewise. * sysdeps/generic/unwind-dw2-fde.c: Likewise. * sysdeps/i386/backtrace.c: Likewise. * sysdeps/ieee754/ldbl-opt/nldbl-compat.c: Likewise. * sysdeps/m68k/backtrace.c: Likewise. * sysdeps/mach/hurd/cthreads.c: Likewise. * sysdeps/mach/hurd/dirstream.h: Likewise. * sysdeps/mach/hurd/malloc-machine.h: Likewise. * sysdeps/nptl/malloc-machine.h: Likewise. * sysdeps/nptl/stdio-lock.h: Likewise. * sysdeps/posix/dirstream.h: Likewise. * sysdeps/posix/getaddrinfo.c: Likewise. * sysdeps/posix/system.c: Likewise. * sysdeps/pthread/aio_suspend.c: Likewise. * sysdeps/s390/s390-32/backtrace.c: Likewise. * sysdeps/s390/s390-64/backtrace.c: Likewise. * sysdeps/unix/sysv/linux/check_pf.c: Likewise. * sysdeps/unix/sysv/linux/if_index.c: Likewise. * sysdeps/unix/sysv/linux/s390/s390-32/getutent_r.c: Likewise. * sysdeps/unix/sysv/linux/s390/s390-32/getutid_r.c: Likewise. * sysdeps/unix/sysv/linux/s390/s390-32/getutline_r.c: Likewise. * sysdeps/unix/sysv/linux/shm-directory.c: Likewise. * sysdeps/unix/sysv/linux/system.c: Likewise. * sysdeps/x86_64/backtrace.c: Likewise. * time/alt_digit.c: Likewise. * time/era.c: Likewise. * time/tzset.c: Likewise. * wcsmbs/wcsmbsload.c: Likewise. * nptl/tst-initializers1.c (do_test): Refer to <libc-lock.h> instead of <bits/libc-lock.h> in comment.
2015-05-21vfprintf: Remove label name switching for the jump tableFlorian Weimer1-17/+4
Different labels are no longer needed because the tables are now in separate functions.
2015-05-21vfprintf: Introduce printf_positional functionFlorian Weimer1-347/+369
This splits a considerable chunk of code from the main vfprintf function. This will make it easier to remove the use of extend_alloca from the positional argument handling code.
2015-05-21vfprintf: Move jump table definition and the macros out of functionFlorian Weimer1-65/+64
The second jump table will be moved to a separate function in the next commit.
2015-03-06vfprintf: Define WORK_BUFFER_SIZEFlorian Weimer1-11/+11
This constant will allow us to refer to the number of elements in work_buffer across a function call boundary.
2015-03-06vfprintf: Introduce JUMP_TABLE_BASE_LABELFlorian Weimer1-3/+6
This makes the offset handling more explicit and avoids cross-references between the jump tables.
2015-03-06vfprintf: Introduce THOUSANDS_SEP_TFlorian Weimer1-18/+5
This avoids preprocessor conditionals in function declarations.
2015-01-02Update copyright dates with scripts/update-copyrights.Joseph Myers1-1/+1
2014-12-15CVE-2012-3406: Stack overflow in vfprintf [BZ #16617]Jeff Law1-2/+38
A larger number of format specifiers coudld cause a stack overflow, potentially allowing to bypass _FORTIFY_SOURCE format string protection.
2014-05-01Correctly handle %p in wprintf (BZ #16890)Andreas Schwab1-1/+2
2014-03-17Revert "Fix _IO_JUMPS_OFFSET -Wundef warnings"Will Newton1-1/+1
This reverts commit f7efd7c3dfffa3c417e9d3c4cb19d9954a3b1421.
2014-03-17Fix _IO_JUMPS_OFFSET -Wundef warningsWill Newton1-1/+1
ChangeLog: 2014-03-17 Will Newton <will.newton@linaro.org> * libio/genops.c: Check whether _IO_JUMPS_OFFSET is defined with #ifdef rather than #if. * libio/libioP.h: Likewise. * stdio-common/vfprintf.c: Likewise.
2014-01-07Fix integer overflow in vfwprintf. Fixes bug 14286.Ondřej Bílka1-1/+7
2014-01-01Update copyright notices with scripts/update-copyrightsAllan McRae1-1/+1
2013-10-11Fix fwrite() reading beyond end of buffer in error pathEric Biggers1-6/+6
Partially revert commits 2b766585f9b4ffabeef2f36200c275976b93f2c7 and de2fd463b1c0310d75084b6d774fb974075a4ad9, which were intended to fix BZ#11741 but caused another, likely worse bug, namely that fwrite() and fputs() could, in an error path, read data beyond the end of the specified buffer, and potentially even write this data to the file. Fix BZ#11741 properly by checking the return value from _IO_padn() in stdio-common/vfprintf.c.
2013-06-07Avoid use of "register" as optimization hint.Joseph Myers1-4/+4
2013-03-05Replace __builtin_expect(..., 0) with __glibc_unlikely().Paul Pluzhnikov1-19/+19
2013-03-05 * stdio-common/vfprintf.c (vfprintf): Check malloc return; don'tPaul Pluzhnikov1-4/+13
call free(NULL).
2013-02-13Remove __ptrvalue, __bounded and __unbounded.Joseph Myers1-2/+2
2013-01-02Update copyright notices with scripts/update-copyrights.Joseph Myers1-1/+1
2012-11-16printf should return negative value on errorSiddhesh Poyarekar1-4/+24
[BZ #11741] Fixed bug where printf and family may return a spurious success when printing padded formats.
2012-09-282012-09-28 Andreas Schwab <schwab@linux-m68k.org>Jeff Law1-36/+3
[BZ #6530] * stdio-common/vfprintf.c (process_string_arg): Revert 2000-07-22 change. 2011-09-28 Jonathan Nieder <jrnieder@gmail.com> * stdio-common/Makefile (tst-sprintf-ENV): Set environment for testcase. * stdio-common/tst-sprintf.c: Include <locale.h> (main): Test sprintf's handling of incomplete multibyte characters.
2012-05-24Remove use of INTDEF/INTUSE in libioAndreas Schwab1-15/+16
2012-04-02Tighten up vfprintf width, precision, and total length overflow handling.David S. Miller1-19/+58
With help from Paul Eggert, Carlos O'Donell, and Roland McGrath. * stdio-common/printf-parse.h (read_int): Change return type to 'int', return -1 on INT_MAX overflow. * stdio-common/vfprintf.c (vfprintf): Validate width and precision against overflow of INT_MAX. Set errno to EOVERFLOW when 'done' overflows INT_MAX. Check for overflow of in-format-string precision values properly. Use EOVERFLOW rather than ERANGE throughout. Use SIZE_MAX not INT_MAX for integer overflow test. * stdio-common/printf-parsemb.c: If read_int signals an overflow, skip the construct in the format string but do not record anything. * stdio-common/bug22.c: Adjust to test both width/prevision INT_MAX overflow as well as total length INT_MAX overflow. Check explicitly for proper errno values.
2012-03-20Move stdio-common/_itoa.h to sysdeps/genericH.J. Lu1-2/+2
2012-03-06Formatting fixesUlrich Drepper1-13/+13
2012-03-052012-03-02 Kees Cook <keescook@chromium.org>Kees Cook1-3/+7
* stdio-common/vfprintf.c (vfprintf): add missing errno settings.
2012-03-052012-03-02 Kees Cook <keescook@chromium.org>Kees Cook1-9/+38
[BZ #13656] * stdio-common/vfprintf.c (vfprintf): Check for nargs overflow and possibly allocate from heap instead of stack. * stdio-common/bug-vfprintf-nargs.c: New file. * stdio-common/Makefile (tests): Add nargs overflow test.
2012-02-09Replace FSF snail mail address with URLs.Paul Eggert1-3/+2
2011-12-17Fix extension of array in extended printf format handlingUlrich Drepper1-7/+6
2011-05-21Set stream errors in more casesUlrich Drepper1-0/+1
Also avoid unnecessarily setting errno when testing for TTY.
2011-02-20Fix allocation when handling positional parameters in printf.Petr Baudis1-2/+3
2010-12-24Always allow overwriting printf modifiers etc.Ulrich Drepper1-7/+13
2009-09-29Check for integer overflows in formatting functionsAndreas Schwab1-18/+31
2009-04-11* stdio-common/printf.h (struct printf_info): Add user element.Ulrich Drepper1-14/+51
New types printf_arginfo_size_function, printf_va_arg_function. Declare register_printf_specifier, register_printf_modifier, register_printf_type. * stdio-common/printf-parse.h (struct printf_spec): Add size element. (union printf_arg): Add pa_user element. Adjust __printf_arginfo_table type. Add __printf_va_arg_table, __printf_modifier_table, __handle_registered_modifier_mb, and __handle_registered_modifier_wc declarations. * stdio-common/printf-parsemb.c: Recognize registered modifiers. If registered arginfo call failed try normal specifier. * stdio-common/printf-prs.c: Pass additional parameter to arginfo function. * stdio-common/Makefile (routines): Add reg-modifier and reg-type. * stdio-common/Versions: Export register_printf_modifier, register_printf_type, and register_printf_specifier for GLIBC_2.10. * stdio-common/reg-modifier.c: New file. * stdio-common/reg-type.c: New file. * stdio-common/reg-printf.c (__register_printf_specifier): New function. Mostly the old __register_printf_function function but uses locking and type of third parameter changed. (__register_printf_function): Implement using __register_printf_specifier. * stdio-common/vfprintf.c (vfprintf): Collect argument sizes in calls to arginfo functions. Allocate enough memory for user-defined types. Call new va_arg functions to get user-defined types. Try installed handlers even for existing format specifiers first.