msvcrt-atof_strtod: Update patchset.

This commit is contained in:
Sebastian Lackner 2015-06-26 10:45:25 +02:00
parent c981072e0d
commit 731305d018
5 changed files with 75 additions and 30 deletions

View File

@ -39,10 +39,11 @@ Wine. All those differences are also documented on the
Included bug fixes and improvements
-----------------------------------
**Bug fixes and features included in the next upcoming release [2]:**
**Bug fixes and features included in the next upcoming release [3]:**
* Globally invalidate key state on changes in other threads ([Wine Bug #29871](https://bugs.winehq.org/show_bug.cgi?id=29871))
* SecuROM 5.x media validation fails ([Wine Bug #21448](https://bugs.winehq.org/show_bug.cgi?id=21448))
* msvcrt.strtod should initialize *end with NULL on failure
**Bug fixes and features in Wine Staging 1.7.45 [244]:**

View File

@ -1,33 +1,15 @@
From 50aadbdd128d6cf1489abdceb91302c53a144cbd Mon Sep 17 00:00:00 2001
From 5464947ce0bbc3f0da79231c5e366cd54d7888d1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Sat, 8 Nov 2014 22:39:28 +0100
Subject: msvcrt: Avoid crash when NULL pointer is passed to atof / strtod
functions.
---
dlls/msvcrt/string.c | 6 +++++
dlls/msvcrt/tests/string.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 63 insertions(+)
1 file changed, 57 insertions(+)
diff --git a/dlls/msvcrt/string.c b/dlls/msvcrt/string.c
index 6f9280f..d933643 100644
--- a/dlls/msvcrt/string.c
+++ b/dlls/msvcrt/string.c
@@ -434,6 +434,12 @@ static double strtod_helper(const char *str, char **end, MSVCRT__locale_t locale
*/
double CDECL MSVCRT_strtod_l(const char *str, char **end, MSVCRT__locale_t locale)
{
+ if (!str)
+ {
+ if (end) *end = NULL;
+ *MSVCRT__errno() = MSVCRT_EINVAL;
+ return 0.0;
+ }
return strtod_helper(str, end, locale, NULL);
}
diff --git a/dlls/msvcrt/tests/string.c b/dlls/msvcrt/tests/string.c
index e2d53d4..187d2b9 100644
index 9920df0..1a3c598 100644
--- a/dlls/msvcrt/tests/string.c
+++ b/dlls/msvcrt/tests/string.c
@@ -89,6 +89,8 @@ static int (__cdecl *p_tolower)(int);
@ -39,7 +21,7 @@ index e2d53d4..187d2b9 100644
static int (__cdecl *p__strnset_s)(char*,size_t,int,size_t);
static int (__cdecl *p__wcsset_s)(wchar_t*,size_t,wchar_t);
@@ -1580,6 +1582,28 @@ static void test__strtod(void)
@@ -1678,6 +1680,28 @@ static void test__strtod(void)
ok(almost_equal(d, 0), "d = %lf\n", d);
ok(end == white_chars, "incorrect end (%d)\n", (int)(end-white_chars));
@ -57,7 +39,7 @@ index e2d53d4..187d2b9 100644
+ d = strtod(NULL, &end);
+ ok(almost_equal(d, 0.0), "d = %lf\n", d);
+ ok(errno == EINVAL, "errno = %x\n", errno);
+ ok(!end, "incorrect end ptr %p\n", end);
+ todo_wine ok(!end, "incorrect end ptr %p\n", end);
+
+ errno = EBADF;
+ d = p__strtod_l(NULL, NULL, NULL);
@ -68,7 +50,7 @@ index e2d53d4..187d2b9 100644
/* Set locale with non '.' decimal point (',') */
if(!setlocale(LC_ALL, "Polish")) {
win_skip("system with limited locales\n");
@@ -2623,6 +2647,36 @@ static void test_atoi(void)
@@ -2721,6 +2745,36 @@ static void test_atoi(void)
ok(r == 0, "atoi(4294967296) = %d\n", r);
}
@ -105,7 +87,7 @@ index e2d53d4..187d2b9 100644
static void test_strncpy(void)
{
#define TEST_STRNCPY_LEN 10
@@ -2831,6 +2885,8 @@ START_TEST(string)
@@ -2959,6 +3013,8 @@ START_TEST(string)
p_mbrtowc = (void*)GetProcAddress(hMsvcrt, "mbrtowc");
p_mbsrtowcs = (void*)GetProcAddress(hMsvcrt, "mbsrtowcs");
p__atodbl_l = (void*)GetProcAddress(hMsvcrt, "_atodbl_l");
@ -114,7 +96,7 @@ index e2d53d4..187d2b9 100644
p__strnset_s = (void*)GetProcAddress(hMsvcrt, "_strnset_s");
p__wcsset_s = (void*)GetProcAddress(hMsvcrt, "_wcsset_s");
@@ -2884,6 +2940,7 @@ START_TEST(string)
@@ -3015,6 +3071,7 @@ START_TEST(string)
test__stricmp();
test__wcstoi64();
test_atoi();
@ -123,5 +105,5 @@ index e2d53d4..187d2b9 100644
test_strxfrm();
test__strnset_s();
--
2.2.1
2.4.3

View File

@ -0,0 +1,45 @@
From 826e80ab90bc03c4e156f3600ae8078b3c75e3ed Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Fri, 26 Jun 2015 10:35:50 +0200
Subject: msvcrt: Set *end to NULL when strtod is called with NULL pointer
string.
---
dlls/msvcrt/string.c | 7 +++++--
dlls/msvcrt/tests/string.c | 2 +-
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/dlls/msvcrt/string.c b/dlls/msvcrt/string.c
index fdeb4e0..980d492 100644
--- a/dlls/msvcrt/string.c
+++ b/dlls/msvcrt/string.c
@@ -317,8 +317,11 @@ static double strtod_helper(const char *str, char **end, MSVCRT__locale_t locale
if(err)
*err = 0;
- else
- if(!MSVCRT_CHECK_PMT(str != NULL)) return 0;
+ else if(!MSVCRT_CHECK_PMT(str != NULL)) {
+ if (end)
+ *end = NULL;
+ return 0;
+ }
if(!locale)
locinfo = get_locinfo();
diff --git a/dlls/msvcrt/tests/string.c b/dlls/msvcrt/tests/string.c
index 1a3c598..83de762 100644
--- a/dlls/msvcrt/tests/string.c
+++ b/dlls/msvcrt/tests/string.c
@@ -1694,7 +1694,7 @@ static void test__strtod(void)
d = strtod(NULL, &end);
ok(almost_equal(d, 0.0), "d = %lf\n", d);
ok(errno == EINVAL, "errno = %x\n", errno);
- todo_wine ok(!end, "incorrect end ptr %p\n", end);
+ ok(!end, "incorrect end ptr %p\n", end);
errno = EBADF;
d = p__strtod_l(NULL, NULL, NULL);
--
2.4.3

View File

@ -1,2 +1 @@
# Fixes: [32550] MSVCRT crashes when NULL is passed as string to atof or strtod
Disabled: True
Fixes: msvcrt.strtod should initialize *end with NULL on failure

View File

@ -149,6 +149,7 @@ patch_enable_all ()
enable_mscoree_CorValidateImage="$1"
enable_msvcp90_basic_string_dtor="$1"
enable_msvcrt_Math_Precision="$1"
enable_msvcrt_atof_strtod="$1"
enable_msvfw32_Image_Size="$1"
enable_ntdll_APC_Performance="$1"
enable_ntdll_APC_Start_Process="$1"
@ -521,6 +522,9 @@ patch_enable ()
msvcrt-Math_Precision)
enable_msvcrt_Math_Precision="$2"
;;
msvcrt-atof_strtod)
enable_msvcrt_atof_strtod="$2"
;;
msvfw32-Image_Size)
enable_msvfw32_Image_Size="$2"
;;
@ -3298,6 +3302,20 @@ if test "$enable_msvcrt_Math_Precision" -eq 1; then
) >> "$patchlist"
fi
# Patchset msvcrt-atof_strtod
# |
# | Modified files:
# | * dlls/msvcrt/string.c, dlls/msvcrt/tests/string.c
# |
if test "$enable_msvcrt_atof_strtod" -eq 1; then
patch_apply msvcrt-atof_strtod/0001-msvcrt-Avoid-crash-when-NULL-pointer-is-passed-to-at.patch
patch_apply msvcrt-atof_strtod/0002-msvcrt-Set-end-to-NULL-when-strtod-is-called-with-NU.patch
(
echo '+ { "Michael Müller", "msvcrt: Avoid crash when NULL pointer is passed to atof / strtod functions.", 1 },';
echo '+ { "Sebastian Lackner", "msvcrt: Set *end to NULL when strtod is called with NULL pointer string.", 1 },';
) >> "$patchlist"
fi
# Patchset msvfw32-Image_Size
# |
# | This patchset fixes the following Wine bugs: