Rob Shearman : wininet: Fix behaviour of InternetTimeFromSystemTimeA/ W when a buffer that is too small is passed in.
Alexandre Julliard
julliard at winehq.org
Thu Oct 2 11:37:22 CDT 2008
Module: wine
Branch: master
Commit: fa066c74e3b96bde9f1c1badc6f1d6e300348079
URL: http://source.winehq.org/git/wine.git/?a=commit;h=fa066c74e3b96bde9f1c1badc6f1d6e300348079
Author: Rob Shearman <robertshearman at gmail.com>
Date: Thu Oct 2 11:38:38 2008 +0100
wininet: Fix behaviour of InternetTimeFromSystemTimeA/W when a buffer that is too small is passed in.
---
dlls/wininet/internet.c | 14 ++++++++++++--
dlls/wininet/tests/http.c | 3 ---
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/dlls/wininet/internet.c b/dlls/wininet/internet.c
index 6166ff8..ea1d294 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,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],
diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c
index db4f075..bfdcf80 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 );
More information about the wine-cvs
mailing list