Commit fa066c74 authored by Rob Shearman's avatar Rob Shearman Committed by Alexandre Julliard

wininet: Fix behaviour of InternetTimeFromSystemTimeA/W when a buffer that is…

wininet: Fix behaviour of InternetTimeFromSystemTimeA/W when a buffer that is too small is passed in.
parent ef0e3792
......@@ -2478,6 +2478,12 @@ BOOL WINAPI InternetTimeFromSystemTimeA( const SYSTEMTIME* time, DWORD format, L
TRACE( "%p 0x%08x %p 0x%08x\n", time, format, string, size );
if (size < INTERNET_RFC1123_BUFSIZE * sizeof(*string))
{
SetLastError(ERROR_INSUFFICIENT_BUFFER);
return FALSE;
}
ret = InternetTimeFromSystemTimeW( time, format, stringW, sizeof(stringW) );
if (ret) WideCharToMultiByte( CP_ACP, 0, stringW, -1, string, size, NULL, NULL );
......@@ -2495,10 +2501,14 @@ BOOL WINAPI InternetTimeFromSystemTimeW( const SYSTEMTIME* time, DWORD format, L
TRACE( "%p 0x%08x %p 0x%08x\n", time, format, string, size );
if (!time || !string) return FALSE;
if (!time || !string || format != INTERNET_RFC1123_FORMAT)
return FALSE;
if (format != INTERNET_RFC1123_FORMAT || size < INTERNET_RFC1123_BUFSIZE * sizeof(WCHAR))
if (size < INTERNET_RFC1123_BUFSIZE * sizeof(*string))
{
SetLastError(ERROR_INSUFFICIENT_BUFFER);
return FALSE;
}
sprintfW( string, date,
WININET_wkday[time->wDayOfWeek],
......
......@@ -800,12 +800,10 @@ static void InternetTimeFromSystemTimeA_test(void)
SetLastError(0xdeadbeef);
ret = pInternetTimeFromSystemTimeA( &time, INTERNET_RFC1123_FORMAT, string, 0 );
error = GetLastError();
todo_wine {
ok( !ret, "InternetTimeFromSystemTimeA should have returned FALSE\n" );
ok( error == ERROR_INSUFFICIENT_BUFFER,
"InternetTimeFromSystemTimeA failed with ERROR_INSUFFICIENT_BUFFER instead of %u\n",
error );
}
}
static void InternetTimeFromSystemTimeW_test(void)
......@@ -827,7 +825,6 @@ static void InternetTimeFromSystemTimeW_test(void)
ret = pInternetTimeFromSystemTimeW( &time, INTERNET_RFC1123_FORMAT, string, sizeof(string)/sizeof(string[0]) );
error = GetLastError();
ok( !ret, "InternetTimeFromSystemTimeW should have returned FALSE\n" );
todo_wine
ok( error == ERROR_INSUFFICIENT_BUFFER,
"InternetTimeFromSystemTimeW failed with ERROR_INSUFFICIENT_BUFFER instead of %u\n",
error );
......
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