mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-16 05:07:36 +00:00
wininet: Properly handle output buffer size in InternetGetCookieA.
This commit is contained in:
parent
0c02e35841
commit
f877fe9ba4
|
@ -678,7 +678,7 @@ BOOL WINAPI InternetGetCookieA(LPCSTR lpszUrl, LPCSTR lpszCookieName,
|
||||||
LPSTR lpCookieData, LPDWORD lpdwSize)
|
LPSTR lpCookieData, LPDWORD lpdwSize)
|
||||||
{
|
{
|
||||||
WCHAR *url, *name;
|
WCHAR *url, *name;
|
||||||
DWORD len;
|
DWORD len, size;
|
||||||
BOOL r;
|
BOOL r;
|
||||||
|
|
||||||
TRACE("(%s %s %p %p(%u))\n", debugstr_a(lpszUrl), debugstr_a(lpszCookieName),
|
TRACE("(%s %s %p %p(%u))\n", debugstr_a(lpszUrl), debugstr_a(lpszCookieName),
|
||||||
|
@ -701,8 +701,18 @@ BOOL WINAPI InternetGetCookieA(LPCSTR lpszUrl, LPCSTR lpszCookieName,
|
||||||
{
|
{
|
||||||
r = InternetGetCookieW( url, name, szCookieData, &len );
|
r = InternetGetCookieW( url, name, szCookieData, &len );
|
||||||
|
|
||||||
*lpdwSize = WideCharToMultiByte( CP_ACP, 0, szCookieData, len,
|
if(r) {
|
||||||
lpCookieData, lpCookieData ? *lpdwSize : 0, NULL, NULL );
|
size = WideCharToMultiByte( CP_ACP, 0, szCookieData, len, NULL, 0, NULL, NULL);
|
||||||
|
if(lpCookieData) {
|
||||||
|
if(*lpdwSize >= size) {
|
||||||
|
WideCharToMultiByte( CP_ACP, 0, szCookieData, len, lpCookieData, *lpdwSize, NULL, NULL);
|
||||||
|
}else {
|
||||||
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
||||||
|
r = FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*lpdwSize = size;
|
||||||
|
}
|
||||||
|
|
||||||
heap_free( szCookieData );
|
heap_free( szCookieData );
|
||||||
}
|
}
|
||||||
|
|
|
@ -414,6 +414,13 @@ static void test_complicated_cookie(void)
|
||||||
ok(strstr(buffer,"M=N")==NULL,"M=N present\n");
|
ok(strstr(buffer,"M=N")==NULL,"M=N present\n");
|
||||||
ok(strstr(buffer,"O=P")==NULL,"O=P present\n");
|
ok(strstr(buffer,"O=P")==NULL,"O=P present\n");
|
||||||
|
|
||||||
|
len = 10;
|
||||||
|
memset(buffer, 0xac, sizeof(buffer));
|
||||||
|
ret = InternetGetCookie("http://testing.example.com", NULL, buffer, &len);
|
||||||
|
ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER,
|
||||||
|
"InternetGetCookie returned: %x(%u), expected ERROR_INSUFFICIENT_BUFFER\n", ret, GetLastError());
|
||||||
|
ok(len == 19, "len = %u\n", len);
|
||||||
|
|
||||||
len = 1024;
|
len = 1024;
|
||||||
ret = InternetGetCookieW(testing_example_comW, NULL, NULL, &len);
|
ret = InternetGetCookieW(testing_example_comW, NULL, NULL, &len);
|
||||||
ok(ret == TRUE,"InternetGetCookieW failed\n");
|
ok(ret == TRUE,"InternetGetCookieW failed\n");
|
||||||
|
|
Loading…
Reference in a new issue