Added patch to postpone setting lpstrFileTitle to work around application bugs.

This commit is contained in:
Sebastian Lackner 2016-04-27 16:39:23 +02:00
parent 5e9e174e71
commit 52c70bd232
3 changed files with 96 additions and 0 deletions

View File

@ -0,0 +1,74 @@
From 022ab9291e3d8c324c7c2dacbfb0b23e234fb4ae Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Tue, 26 Apr 2016 18:28:21 +0800
Subject: comdlg32: Postpone setting ofn->lpstrFileTitle to work around an
application bug.
An application in the bug 38400 passes a not initialized ofn->lpstrFileTitle
to GetSaveFileNameW(). Basically ofn->lpstrFileTitle points to the stack
approximately 428 bytes above the current stack pointer, and since Wine's
GetSaveFileNameW() uses more than 4096 bytes one of internal stack frames is
guaranteed to be trashed after copying file name to ofn->lpstrFileTitle.
---
dlls/comdlg32/filedlg.c | 31 ++++++++++++++-----------------
1 file changed, 14 insertions(+), 17 deletions(-)
diff --git a/dlls/comdlg32/filedlg.c b/dlls/comdlg32/filedlg.c
index 1453396..6a6a093 100644
--- a/dlls/comdlg32/filedlg.c
+++ b/dlls/comdlg32/filedlg.c
@@ -463,6 +463,13 @@ static BOOL GetFileDialog95A(LPOPENFILENAMEA ofn,UINT iDlgType)
ret = FALSE;
}
+ /* set the lpstrFileTitle */
+ if (ret && ofn->lpstrFile && ofn->lpstrFileTitle)
+ {
+ LPSTR lpstrFileTitle = PathFindFileNameA(ofn->lpstrFile);
+ lstrcpynA(ofn->lpstrFileTitle, lpstrFileTitle, ofn->nMaxFileTitle);
+ }
+
if (lpstrSavDir)
{
SetCurrentDirectoryA(lpstrSavDir);
@@ -555,6 +562,13 @@ static BOOL GetFileDialog95W(LPOPENFILENAMEW ofn,UINT iDlgType)
ret = FALSE;
}
+ /* set the lpstrFileTitle */
+ if (ret && ofn->lpstrFile && ofn->lpstrFileTitle)
+ {
+ LPWSTR lpstrFileTitle = PathFindFileNameW(ofn->lpstrFile);
+ lstrcpynW(ofn->lpstrFileTitle, lpstrFileTitle, ofn->nMaxFileTitle);
+ }
+
if (lpstrSavDir)
{
SetCurrentDirectoryW(lpstrSavDir);
@@ -2735,23 +2749,6 @@ BOOL FILEDLG95_OnOpen(HWND hwnd)
fodInfos->ofnInfos->nFileExtension = (*lpszTemp) ? (lpszTemp - tempFileA) + 1 : 0;
}
- /* set the lpstrFileTitle */
- if(fodInfos->ofnInfos->lpstrFileTitle)
- {
- LPWSTR lpstrFileTitle = PathFindFileNameW(lpstrPathAndFile);
- if(fodInfos->unicode)
- {
- LPOPENFILENAMEW ofn = fodInfos->ofnInfos;
- lstrcpynW(ofn->lpstrFileTitle, lpstrFileTitle, ofn->nMaxFileTitle);
- }
- else
- {
- LPOPENFILENAMEA ofn = (LPOPENFILENAMEA)fodInfos->ofnInfos;
- WideCharToMultiByte(CP_ACP, 0, lpstrFileTitle, -1,
- ofn->lpstrFileTitle, ofn->nMaxFileTitle, NULL, NULL);
- }
- }
-
/* copy currently selected filter to lpstrCustomFilter */
if (fodInfos->ofnInfos->lpstrCustomFilter)
{
--
2.8.0

View File

@ -0,0 +1,2 @@
Fixes: [38400] Postpone setting lpstrFileTitle in GetSaveFileNameW
Fixes: [35200] Postpone setting lpstrFileTitle in GetSaveFileNameA

View File

@ -97,6 +97,7 @@ patch_enable_all ()
enable_comctl32_Button_Theming="$1"
enable_comctl32_PROPSHEET_InsertPage="$1"
enable_comctl32_TTM_ADDTOOLW="$1"
enable_comdlg32_lpstrFileTitle="$1"
enable_configure_Absolute_RPATH="$1"
enable_crypt32_CMS_Certificates="$1"
enable_crypt32_CryptUnprotectMemory="$1"
@ -461,6 +462,9 @@ patch_enable ()
comctl32-TTM_ADDTOOLW)
enable_comctl32_TTM_ADDTOOLW="$2"
;;
comdlg32-lpstrFileTitle)
enable_comdlg32_lpstrFileTitle="$2"
;;
configure-Absolute_RPATH)
enable_configure_Absolute_RPATH="$2"
;;
@ -2794,6 +2798,22 @@ if test "$enable_comctl32_TTM_ADDTOOLW" -eq 1; then
) >> "$patchlist"
fi
# Patchset comdlg32-lpstrFileTitle
# |
# | This patchset fixes the following Wine bugs:
# | * [#38400] Postpone setting lpstrFileTitle in GetSaveFileNameW
# | * [#35200] Postpone setting lpstrFileTitle in GetSaveFileNameA
# |
# | Modified files:
# | * dlls/comdlg32/filedlg.c
# |
if test "$enable_comdlg32_lpstrFileTitle" -eq 1; then
patch_apply comdlg32-lpstrFileTitle/0001-comdlg32-Postpone-setting-ofn-lpstrFileTitle-to-work.patch
(
echo '+ { "Dmitry Timoshkov", "comdlg32: Postpone setting ofn->lpstrFileTitle to work around an application bug.", 1 },';
) >> "$patchlist"
fi
# Patchset configure-Absolute_RPATH
# |
# | This patchset fixes the following Wine bugs: