Commit 353962d5 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

Fixed ShellMessageBox[AW] buffers usage (in some cases, wrong buffers

were used ; destination buffer doesn't have a fixed size). Fixed FormatMessage parameter warnings (it's now a va_list*).
parent 1841a2ac
...@@ -218,9 +218,11 @@ int WINAPIV ShellMessageBoxW( ...@@ -218,9 +218,11 @@ int WINAPIV ShellMessageBoxW(
UINT uType, UINT uType,
...) ...)
{ {
WCHAR szText[100],szTitle[100],szTemp[256]; WCHAR szText[100],szTitle[100];
LPCWSTR pszText = szText, pszTitle = szTitle; LPCWSTR pszText = szText, pszTitle = szTitle, pszTemp;
va_list args; va_list args;
int ret;
va_start(args, uType); va_start(args, uType);
/* wvsprintfA(buf,fmt, args); */ /* wvsprintfA(buf,fmt, args); */
...@@ -228,21 +230,23 @@ int WINAPIV ShellMessageBoxW( ...@@ -228,21 +230,23 @@ int WINAPIV ShellMessageBoxW(
(DWORD)hInstance,(DWORD)hWnd,lpText,lpCaption,uType); (DWORD)hInstance,(DWORD)hWnd,lpText,lpCaption,uType);
if (!HIWORD(lpCaption)) if (!HIWORD(lpCaption))
LoadStringW(hInstance, (DWORD)lpCaption, szTitle, 100); LoadStringW(hInstance, (DWORD)lpCaption, szTitle, sizeof(szTitle)/sizeof(szTitle[0]));
else else
pszTitle = lpCaption; pszTitle = lpCaption;
if (!HIWORD(lpText)) if (!HIWORD(lpText))
LoadStringW(hInstance, (DWORD)lpText, szText, 100); LoadStringW(hInstance, (DWORD)lpText, szText, sizeof(szText)/sizeof(szText[0]));
else else
pszText = lpText; pszText = lpText;
FormatMessageW(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY, FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING,
szText, 0, 0, szTemp, 256, (LPDWORD) args); pszText, 0, 0, (LPWSTR)&pszTemp, 0, &args);
va_end(args); va_end(args);
return MessageBoxW(hWnd,szTemp,szTitle,uType); ret = MessageBoxW(hWnd,pszTemp,pszTitle,uType);
LocalFree((HLOCAL)pszTemp);
return ret;
} }
/************************************************************************* /*************************************************************************
...@@ -256,9 +260,11 @@ int WINAPIV ShellMessageBoxA( ...@@ -256,9 +260,11 @@ int WINAPIV ShellMessageBoxA(
UINT uType, UINT uType,
...) ...)
{ {
char szText[100],szTitle[100],szTemp[256]; char szText[100],szTitle[100];
LPCSTR pszText = szText, pszTitle = szTitle; LPCSTR pszText = szText, pszTitle = szTitle, pszTemp;
va_list args; va_list args;
int ret;
va_start(args, uType); va_start(args, uType);
/* wvsprintfA(buf,fmt, args); */ /* wvsprintfA(buf,fmt, args); */
...@@ -266,21 +272,23 @@ int WINAPIV ShellMessageBoxA( ...@@ -266,21 +272,23 @@ int WINAPIV ShellMessageBoxA(
(DWORD)hInstance,(DWORD)hWnd,lpText,lpCaption,uType); (DWORD)hInstance,(DWORD)hWnd,lpText,lpCaption,uType);
if (!HIWORD(lpCaption)) if (!HIWORD(lpCaption))
LoadStringA(hInstance, (DWORD)lpCaption, szTitle, 100); LoadStringA(hInstance, (DWORD)lpCaption, szTitle, sizeof(szTitle));
else else
pszTitle = lpCaption; pszTitle = lpCaption;
if (!HIWORD(lpText)) if (!HIWORD(lpText))
LoadStringA(hInstance, (DWORD)lpText, szText, 100); LoadStringA(hInstance, (DWORD)lpText, szText, sizeof(szText));
else else
pszText = lpText; pszText = lpText;
FormatMessageA(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY, FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING,
szText, 0, 0, szTemp, 256, (LPDWORD) args); pszText, 0, 0, (LPSTR)&pszTemp, 0, &args);
va_end(args); va_end(args);
return MessageBoxA(hWnd,szTemp,szTitle,uType); ret = MessageBoxA(hWnd,pszTemp,pszTitle,uType);
LocalFree((HLOCAL)pszTemp);
return ret;
} }
/************************************************************************* /*************************************************************************
......
...@@ -23,7 +23,7 @@ static BOOL SHELL_WarnFolderDelete (int nKindOfDialog, LPCSTR szDir) ...@@ -23,7 +23,7 @@ static BOOL SHELL_WarnFolderDelete (int nKindOfDialog, LPCSTR szDir)
LoadStringA(shell32_hInstance, IDS_DELETEFOLDER_TEXT, szText, sizeof(szText)); LoadStringA(shell32_hInstance, IDS_DELETEFOLDER_TEXT, szText, sizeof(szText));
LoadStringA(shell32_hInstance, IDS_DELETEFOLDER_CAPTION, szCaption, sizeof(szCaption)); LoadStringA(shell32_hInstance, IDS_DELETEFOLDER_CAPTION, szCaption, sizeof(szCaption));
FormatMessageA(FORMAT_MESSAGE_FROM_STRING|FORMAT_MESSAGE_ARGUMENT_ARRAY, FormatMessageA(FORMAT_MESSAGE_FROM_STRING|FORMAT_MESSAGE_ARGUMENT_ARRAY,
szText, 0, 0, szBuffer, sizeof(szBuffer), (DWORD*)&szDir); szText, 0, 0, szBuffer, sizeof(szBuffer), (va_list*)&szDir);
return (IDOK == MessageBoxA(GetActiveWindow(), szBuffer, szCaption, MB_OKCANCEL | MB_ICONEXCLAMATION)); return (IDOK == MessageBoxA(GetActiveWindow(), szBuffer, szCaption, MB_OKCANCEL | MB_ICONEXCLAMATION));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment