comctl32: datetime: Reject out of range dates in DTM_SETSYSTEMTIME : try 2

Kanit Therdsteerasukdi therdste at cs.ucla.edu
Mon Mar 12 17:19:16 CDT 2007


This fixes one todo_wine. DTM_SETSYTEMTIME should return 0 if the input 
lpSysTime of type SYSTEMTIME is out of range.  The mail client I used 
before had problems attaching the patch.  So here is the patch attached.

-------------- next part --------------
>From b44523cd95cee21d80e66c5ebdfe7c1a5db3c773 Mon Sep 17 00:00:00 2001
From: Kanit Therdsteerasukdi <therdste at ucla.edu>
Date: Thu, 8 Mar 2007 13:29:33 -0800
Subject: [PATCH] bug fix - DTM_SETSYSTEMTIME should return 0 when lpSysTime is not within valid range.

---
 dlls/comctl32/datetime.c       |   11 +++++++++++
 dlls/comctl32/tests/datetime.c |    6 ++----
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/dlls/comctl32/datetime.c b/dlls/comctl32/datetime.c
index 7b24403..08e0d58 100644
--- a/dlls/comctl32/datetime.c
+++ b/dlls/comctl32/datetime.c
@@ -160,6 +160,17 @@ DATETIME_SetSystemTime (DATETIME_INFO *infoPtr, DWORD flag, SYSTEMTIME *lprgSysT
           lprgSysTimeArray->wYear, lprgSysTimeArray->wMonth, lprgSysTimeArray->wDay,
           lprgSysTimeArray->wHour, lprgSysTimeArray->wMinute, lprgSysTimeArray->wSecond);
 
+    if (lprgSysTimeArray->wYear < 1601 || lprgSysTimeArray->wYear > 30827 ||
+	lprgSysTimeArray->wMonth < 1 || lprgSysTimeArray->wMonth > 12 ||
+	lprgSysTimeArray->wDayOfWeek > 6 ||
+	lprgSysTimeArray->wDay < 1 || lprgSysTimeArray->wDay > 31 ||
+	lprgSysTimeArray->wHour > 23 ||
+	lprgSysTimeArray->wMinute > 59 ||
+	lprgSysTimeArray->wSecond > 59 ||
+	lprgSysTimeArray->wMilliseconds > 999
+	)
+      return 0;
+
     if (flag == GDT_VALID) {
         infoPtr->dateValid = TRUE;
         MONTHCAL_CopyTime (lprgSysTimeArray, &infoPtr->date);
diff --git a/dlls/comctl32/tests/datetime.c b/dlls/comctl32/tests/datetime.c
index 0d84df6..8fae8ff 100644
--- a/dlls/comctl32/tests/datetime.c
+++ b/dlls/comctl32/tests/datetime.c
@@ -509,10 +509,8 @@ static void test_dtm_set_and_get_system_time(HWND hWndDateTime)
     /* set st to invalid value */
     fill_systime_struct(&st, 0, 0, 7, 0, 24, 60, 60, 1000);
 
-    todo_wine {
-        r = SendMessage(hWndDateTime, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&st);
-        expect_unsuccess(0, r);
-    }
+    r = SendMessage(hWndDateTime, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&st);
+    expect_unsuccess(0, r);
 
     ok_sequence(sequences, DATETIME_SEQ_INDEX, test_dtm_set_and_get_system_time_seq, "test_dtm_set_and_get_system_time", FALSE);
     flush_sequences(sequences, NUM_MSG_SEQUENCES);
-- 
1.4.4.4



More information about the wine-patches mailing list