diff --git a/dlls/wininet/internet.c b/dlls/wininet/internet.c index 6166ff8673c..ea1d294683e 100644 --- a/dlls/wininet/internet.c +++ b/dlls/wininet/internet.c @@ -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,11 +2501,15 @@ 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 (format != INTERNET_RFC1123_FORMAT || size < INTERNET_RFC1123_BUFSIZE * sizeof(WCHAR)) + if (!time || !string || format != INTERNET_RFC1123_FORMAT) return FALSE; + if (size < INTERNET_RFC1123_BUFSIZE * sizeof(*string)) + { + SetLastError(ERROR_INSUFFICIENT_BUFFER); + return FALSE; + } + sprintfW( string, date, WININET_wkday[time->wDayOfWeek], time->wDay, diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c index db4f075c370..bfdcf80b7c6 100644 --- a/dlls/wininet/tests/http.c +++ b/dlls/wininet/tests/http.c @@ -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 );