=?UTF-8?Q?Andr=C3=A9=20Hentschel=20?=: cryptnet: Use the constants from the wininet header.
Alexandre Julliard
julliard at winehq.org
Mon Sep 5 13:26:22 CDT 2011
Module: wine
Branch: master
Commit: 220191abe1de3614c1512704f4ada9881bacdd7e
URL: http://source.winehq.org/git/wine.git/?a=commit;h=220191abe1de3614c1512704f4ada9881bacdd7e
Author: André Hentschel <nerv at dawncrow.de>
Date: Sun Sep 4 19:29:35 2011 +0200
cryptnet: Use the constants from the wininet header.
---
dlls/cryptnet/cryptnet_main.c | 41 +++++++++++++++++++++++++++++------------
1 files changed, 29 insertions(+), 12 deletions(-)
diff --git a/dlls/cryptnet/cryptnet_main.c b/dlls/cryptnet/cryptnet_main.c
index ec9dddd..6464908 100644
--- a/dlls/cryptnet/cryptnet_main.c
+++ b/dlls/cryptnet/cryptnet_main.c
@@ -583,16 +583,25 @@ static BOOL CRYPT_CrackUrl(LPCWSTR pszURL, URL_COMPONENTSW *components)
memset(components, 0, sizeof(*components));
components->dwStructSize = sizeof(*components);
- components->lpszHostName = CryptMemAlloc(MAX_PATH * sizeof(WCHAR));
- components->dwHostNameLength = MAX_PATH;
- components->lpszUrlPath = CryptMemAlloc(MAX_PATH * 2 * sizeof(WCHAR));
- components->dwUrlPathLength = 2 * MAX_PATH;
+ components->lpszHostName = CryptMemAlloc(INTERNET_MAX_HOST_NAME_LENGTH * sizeof(WCHAR));
+ components->dwHostNameLength = INTERNET_MAX_HOST_NAME_LENGTH;
+ if (!components->lpszHostName)
+ {
+ SetLastError(ERROR_OUTOFMEMORY);
+ return FALSE;
+ }
+ components->lpszUrlPath = CryptMemAlloc(INTERNET_MAX_PATH_LENGTH * sizeof(WCHAR));
+ components->dwUrlPathLength = INTERNET_MAX_PATH_LENGTH;
+ if (!components->lpszUrlPath)
+ {
+ CryptMemFree(components->lpszHostName);
+ SetLastError(ERROR_OUTOFMEMORY);
+ return FALSE;
+ }
+
ret = InternetCrackUrlW(pszURL, 0, ICU_DECODE, components);
if (ret)
{
- if ((components->dwUrlPathLength == 2 * MAX_PATH - 1) ||
- (components->dwHostNameLength == MAX_PATH - 1))
- FIXME("Buffers are too small\n");
switch (components->nScheme)
{
case INTERNET_SCHEME_FTP:
@@ -1025,16 +1034,19 @@ static BOOL WINAPI File_RetrieveEncodedObjectW(LPCWSTR pszURL,
*ppfnFreeObject = CRYPT_FreeBlob;
*ppvFreeContext = NULL;
- components.lpszUrlPath = CryptMemAlloc(MAX_PATH * 2 * sizeof(WCHAR));
- components.dwUrlPathLength = 2 * MAX_PATH;
+ components.lpszUrlPath = CryptMemAlloc(INTERNET_MAX_PATH_LENGTH * sizeof(WCHAR));
+ components.dwUrlPathLength = INTERNET_MAX_PATH_LENGTH;
+ if (!components.lpszUrlPath)
+ {
+ SetLastError(ERROR_OUTOFMEMORY);
+ return FALSE;
+ }
+
ret = InternetCrackUrlW(pszURL, 0, ICU_DECODE, &components);
if (ret)
{
LPWSTR path;
- if (components.dwUrlPathLength == 2 * MAX_PATH - 1)
- FIXME("Buffers are too small\n");
-
/* 3 == lstrlenW(L"c:") + 1 */
path = CryptMemAlloc((components.dwUrlPathLength + 3) * sizeof(WCHAR));
if (path)
@@ -1087,6 +1099,11 @@ static BOOL WINAPI File_RetrieveEncodedObjectW(LPCWSTR pszURL,
ret = FALSE;
CryptMemFree(path);
}
+ else
+ {
+ SetLastError(ERROR_OUTOFMEMORY);
+ ret = FALSE;
+ }
}
CryptMemFree(components.lpszUrlPath);
return ret;
More information about the wine-cvs
mailing list