This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug math/16961] nan function incorrect handling of bad sequences


https://sourceware.org/bugzilla/show_bug.cgi?id=16961

--- Comment #5 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  e02cabecf0d025ec4f4ddee290bdf7aadb873bb3 (commit)
      from  a7f0c5ae4184916f0e145de3aefc794bf2e280ad (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=e02cabecf0d025ec4f4ddee290bdf7aadb873bb3

commit e02cabecf0d025ec4f4ddee290bdf7aadb873bb3
Author: Joseph Myers <joseph@codesourcery.com>
Date:   Tue Nov 24 22:24:52 2015 +0000

    Refactor strtod parsing of NaN payloads.

    The nan* functions handle their string argument by constructing a
    NAN(...) string on the stack as a VLA and passing it to strtod
    functions.

    This approach has problems discussed in bug 16961 and bug 16962: the
    stack usage is unbounded, and it gives incorrect results in certain
    cases where the argument is not a valid n-char-sequence.

    The natural fix for both issues is to refactor the NaN payload parsing
    out of strtod into a separate function that the nan* functions can
    call directly, so that no temporary string needs constructing on the
    stack at all.  This patch does that refactoring in preparation for
    fixing those bugs (but without actually using the new functions from
    nan* - which will also require exporting them from libc at version
    GLIBC_PRIVATE).  This patch is not intended to change any user-visible
    behavior, so no tests are added (fixes for the above bugs will of
    course add tests for them).

    This patch builds on my recent fixes for strtol and strtod issues in
    Turkish locales.  Given those fixes, the parsing of NaN payloads is
    locale-independent; thus, the new functions do not need to take a
    locale_t argument.

    Tested for x86_64, x86, mips64 and powerpc.

        * stdlib/strtod_nan.c: New file.
        * stdlib/strtod_nan_double.h: Likewise.
        * stdlib/strtod_nan_float.h: Likewise.
        * stdlib/strtod_nan_main.c: Likewise.
        * stdlib/strtod_nan_narrow.h: Likewise.
        * stdlib/strtod_nan_wide.h: Likewise.
        * stdlib/strtof_nan.c: Likewise.
        * stdlib/strtold_nan.c: Likewise.
        * sysdeps/ieee754/ldbl-128/strtod_nan_ldouble.h: Likewise.
        * sysdeps/ieee754/ldbl-128ibm/strtod_nan_ldouble.h: Likewise.
        * sysdeps/ieee754/ldbl-96/strtod_nan_ldouble.h: Likewise.
        * wcsmbs/wcstod_nan.c: Likewise.
        * wcsmbs/wcstof_nan.c: Likewise.
        * wcsmbs/wcstold_nan.c: Likewise.
        * stdlib/Makefile (routines): Add strtof_nan, strtod_nan and
        strtold_nan.
        * wcsmbs/Makefile (routines): Add wcstod_nan, wcstold_nan and
        wcstof_nan.
        * include/stdlib.h (__strtof_nan): Declare and use
        libc_hidden_proto.
        (__strtod_nan): Likewise.
        (__strtold_nan): Likewise.
        (__wcstof_nan): Likewise.
        (__wcstod_nan): Likewise.
        (__wcstold_nan): Likewise.
        * include/wchar.h (____wcstoull_l_internal): Declare.
        * stdlib/strtod_l.c: Do not include <ieee754.h>.
        (____strtoull_l_internal): Remove declaration.
        (STRTOF_NAN): Define macro.
        (SET_MANTISSA): Remove macro.
        (STRTOULL): Likewise.
        (____STRTOF_INTERNAL): Use STRTOF_NAN to parse NaN payload.
        * stdlib/strtof_l.c (____strtoull_l_internal): Remove declaration.
        (STRTOF_NAN): Define macro.
        (SET_MANTISSA): Remove macro.
        * sysdeps/ieee754/ldbl-128/strtold_l.c (STRTOF_NAN): Define macro.
        (SET_MANTISSA): Remove macro.
        * sysdeps/ieee754/ldbl-128ibm/strtold_l.c (STRTOF_NAN): Define
        macro.
        (SET_MANTISSA): Remove macro.
        * sysdeps/ieee754/ldbl-64-128/strtold_l.c (STRTOF_NAN): Define
        macro.
        (SET_MANTISSA): Remove macro.
        * sysdeps/ieee754/ldbl-96/strtold_l.c (STRTOF_NAN): Define macro.
        (SET_MANTISSA): Remove macro.
        * wcsmbs/wcstod_l.c (____wcstoull_l_internal): Remove declaration.
        * wcsmbs/wcstof_l.c (____wcstoull_l_internal): Likewise.
        * wcsmbs/wcstold_l.c (____wcstoull_l_internal): Likewise.

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                                        |   49 +++++++++++++++++
 include/stdlib.h                                 |   18 ++++++
 include/wchar.h                                  |    3 +
 stdlib/Makefile                                  |    1 +
 stdlib/strtod_l.c                                |   48 +++-------------
 stdlib/strtod_nan.c                              |   24 ++++++++
 stdlib/strtod_nan_double.h                       |   30 ++++++++++
 stdlib/strtod_nan_float.h                        |   29 ++++++++++
 stdlib/strtod_nan_main.c                         |   63 ++++++++++++++++++++++
 stdlib/strtod_nan_narrow.h                       |   22 ++++++++
 stdlib/strtod_nan_wide.h                         |   22 ++++++++
 stdlib/strtof_l.c                                |   11 +---
 stdlib/strtof_nan.c                              |   24 ++++++++
 stdlib/strtold_nan.c                             |   30 ++++++++++
 sysdeps/ieee754/ldbl-128/strtod_nan_ldouble.h    |   33 +++++++++++
 sysdeps/ieee754/ldbl-128/strtold_l.c             |   13 +----
 sysdeps/ieee754/ldbl-128ibm/strtod_nan_ldouble.h |   30 ++++++++++
 sysdeps/ieee754/ldbl-128ibm/strtold_l.c          |   10 +---
 sysdeps/ieee754/ldbl-64-128/strtold_l.c          |   13 +----
 sysdeps/ieee754/ldbl-96/strtod_nan_ldouble.h     |   30 ++++++++++
 sysdeps/ieee754/ldbl-96/strtold_l.c              |   10 +---
 wcsmbs/Makefile                                  |    1 +
 wcsmbs/wcstod_l.c                                |    3 -
 wcsmbs/wcstod_nan.c                              |   23 ++++++++
 wcsmbs/wcstof_l.c                                |    3 -
 wcsmbs/wcstof_nan.c                              |   23 ++++++++
 wcsmbs/wcstold_l.c                               |    3 -
 wcsmbs/wcstold_nan.c                             |   30 ++++++++++
 28 files changed, 504 insertions(+), 95 deletions(-)
 create mode 100644 stdlib/strtod_nan.c
 create mode 100644 stdlib/strtod_nan_double.h
 create mode 100644 stdlib/strtod_nan_float.h
 create mode 100644 stdlib/strtod_nan_main.c
 create mode 100644 stdlib/strtod_nan_narrow.h
 create mode 100644 stdlib/strtod_nan_wide.h
 create mode 100644 stdlib/strtof_nan.c
 create mode 100644 stdlib/strtold_nan.c
 create mode 100644 sysdeps/ieee754/ldbl-128/strtod_nan_ldouble.h
 create mode 100644 sysdeps/ieee754/ldbl-128ibm/strtod_nan_ldouble.h
 create mode 100644 sysdeps/ieee754/ldbl-96/strtod_nan_ldouble.h
 create mode 100644 wcsmbs/wcstod_nan.c
 create mode 100644 wcsmbs/wcstof_nan.c
 create mode 100644 wcsmbs/wcstold_nan.c

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]