CVE-2017-15670: glob: Fix one-byte overflow [BZ #22320]
[glibc.git] / stdlib / strtold.c
blob4e683b44b63941f3bd60962cfecc462174496229
1 /* Read decimal floating point numbers.
2 This file is part of the GNU C Library.
3 Copyright (C) 1995-2017 Free Software Foundation, Inc.
4 Contributed by Ulrich Drepper <drepper@gnu.org>, 1995.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
20 /* The actual implementation for all floating point sizes is in strtod.c.
21 These macros tell it to produce the `float' version, `strtof'. */
23 #include <bits/floatn.h>
24 #include <bits/long-double.h>
26 #if __HAVE_FLOAT128 && !__HAVE_DISTINCT_FLOAT128
27 # define strtof128 __hide_strtof128
28 # define wcstof128 __hide_wcstof128
29 #endif
31 #ifdef __LONG_DOUBLE_MATH_OPTIONAL
32 # include <wchar.h>
33 # define NEW(x) NEW1(x)
34 # define NEW1(x) __new_##x
35 long double ____new_strtold_internal (const char *, char **, int);
36 long double __new_strtold (const char *, char **);
37 long double ____new_wcstold_internal (const wchar_t *, wchar_t **, int);
38 long double __new_wcstold (const wchar_t *, wchar_t **);
39 libc_hidden_proto (____new_strtold_internal)
40 libc_hidden_proto (____new_wcstold_internal)
41 libc_hidden_proto (__new_strtold)
42 libc_hidden_proto (__new_wcstold)
43 #else
44 # define NEW(x) x
45 #endif
47 #define FLOAT long double
48 #define FLT LDBL
49 #ifdef USE_WIDE_CHAR
50 # define STRTOF NEW (wcstold)
51 # define STRTOF_L __wcstold_l
52 #else
53 # define STRTOF NEW (strtold)
54 # define STRTOF_L __strtold_l
55 #endif
57 #include "strtod.c"
59 #ifdef __LONG_DOUBLE_MATH_OPTIONAL
60 # include <math_ldbl_opt.h>
61 # ifdef USE_WIDE_CHAR
62 long_double_symbol (libc, __new_wcstold, wcstold);
63 long_double_symbol (libc, ____new_wcstold_internal, __wcstold_internal);
64 libc_hidden_ver (____new_wcstold_internal, __wcstold_internal)
65 # else
66 long_double_symbol (libc, __new_strtold, strtold);
67 long_double_symbol (libc, ____new_strtold_internal, __strtold_internal);
68 libc_hidden_ver (____new_strtold_internal, __strtold_internal)
69 # endif
70 #endif
72 #if __HAVE_FLOAT128 && !__HAVE_DISTINCT_FLOAT128
73 # undef strtof128
74 # undef wcstof128
75 # ifdef USE_WIDE_CHAR
76 weak_alias (NEW (wcstold), wcstof128)
77 # else
78 weak_alias (NEW (strtold), strtof128)
79 # endif
80 #endif