Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
c8c3c4be
Commit
c8c3c4be
authored
Mar 08, 2012
by
Owen Rudge
Committed by
Alexandre Julliard
Mar 12, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
comctl32/datetime: Check dates are within range in SetSystemTime.
parent
300140e2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
4 deletions
+49
-4
comctl32.h
dlls/comctl32/comctl32.h
+1
-0
datetime.c
dlls/comctl32/datetime.c
+45
-1
monthcal.c
dlls/comctl32/monthcal.c
+1
-1
datetime.c
dlls/comctl32/tests/datetime.c
+2
-2
No files found.
dlls/comctl32/comctl32.h
View file @
c8c3c4be
...
...
@@ -231,6 +231,7 @@ extern void UPDOWN_Unregister(void) DECLSPEC_HIDDEN;
int
MONTHCAL_MonthLength
(
int
month
,
int
year
)
DECLSPEC_HIDDEN
;
int
MONTHCAL_CalculateDayOfWeek
(
SYSTEMTIME
*
date
,
BOOL
inplace
)
DECLSPEC_HIDDEN
;
LONG
MONTHCAL_CompareSystemTime
(
const
SYSTEMTIME
*
first
,
const
SYSTEMTIME
*
second
)
DECLSPEC_HIDDEN
;
extern
void
THEMING_Initialize
(
void
)
DECLSPEC_HIDDEN
;
extern
void
THEMING_Uninitialize
(
void
)
DECLSPEC_HIDDEN
;
...
...
dlls/comctl32/datetime.c
View file @
c8c3c4be
...
...
@@ -138,6 +138,9 @@ static BOOL DATETIME_SendDateTimeChangeNotify (const DATETIME_INFO *infoPtr);
static
const
WCHAR
allowedformatchars
[]
=
{
'd'
,
'h'
,
'H'
,
'm'
,
'M'
,
's'
,
't'
,
'y'
,
'X'
,
0
};
static
const
int
maxrepetition
[]
=
{
4
,
2
,
2
,
2
,
4
,
2
,
2
,
4
,
-
1
};
/* valid date limits */
static
const
SYSTEMTIME
max_allowed_date
=
{
/* wYear */
9999
,
/* wMonth */
12
,
/* wDayOfWeek */
0
,
/* wDay */
31
};
static
const
SYSTEMTIME
min_allowed_date
=
{
/* wYear */
1752
,
/* wMonth */
9
,
/* wDayOfWeek */
0
,
/* wDay */
14
};
static
DWORD
DATETIME_GetSystemTime
(
const
DATETIME_INFO
*
infoPtr
,
SYSTEMTIME
*
systime
)
...
...
@@ -153,6 +156,43 @@ DATETIME_GetSystemTime (const DATETIME_INFO *infoPtr, SYSTEMTIME *systime)
return
GDT_VALID
;
}
/* Checks value is within configured date range
*
* PARAMETERS
*
* [I] infoPtr : valid pointer to control data
* [I] date : pointer to valid date data to check
*
* RETURN VALUE
*
* TRUE - date within configured range
* FALSE - date is outside configured range
*/
static
BOOL
DATETIME_IsDateInValidRange
(
const
DATETIME_INFO
*
infoPtr
,
const
SYSTEMTIME
*
date
)
{
SYSTEMTIME
range
[
2
];
DWORD
limits
;
if
((
MONTHCAL_CompareSystemTime
(
date
,
&
max_allowed_date
)
==
1
)
||
(
MONTHCAL_CompareSystemTime
(
date
,
&
min_allowed_date
)
==
-
1
))
return
FALSE
;
limits
=
SendMessageW
(
infoPtr
->
hMonthCal
,
MCM_GETRANGE
,
0
,
(
LPARAM
)
&
range
);
if
(
limits
&
GDTR_MAX
)
{
if
(
MONTHCAL_CompareSystemTime
(
date
,
&
range
[
1
])
==
1
)
return
FALSE
;
}
if
(
limits
&
GDTR_MIN
)
{
if
(
MONTHCAL_CompareSystemTime
(
date
,
&
range
[
0
])
==
-
1
)
return
FALSE
;
}
return
TRUE
;
}
static
BOOL
DATETIME_SetSystemTime
(
DATETIME_INFO
*
infoPtr
,
DWORD
flag
,
const
SYSTEMTIME
*
systime
)
...
...
@@ -164,7 +204,7 @@ DATETIME_SetSystemTime (DATETIME_INFO *infoPtr, DWORD flag, const SYSTEMTIME *sy
systime
->
wHour
,
systime
->
wMinute
,
systime
->
wSecond
);
if
(
flag
==
GDT_VALID
)
{
if
(
systime
->
wYear
<
1601
||
systime
->
wYear
>
30827
||
if
(
systime
->
wYear
==
0
||
systime
->
wMonth
<
1
||
systime
->
wMonth
>
12
||
systime
->
wDay
<
1
||
systime
->
wDay
>
MONTHCAL_MonthLength
(
systime
->
wMonth
,
systime
->
wYear
)
||
...
...
@@ -175,6 +215,10 @@ DATETIME_SetSystemTime (DATETIME_INFO *infoPtr, DWORD flag, const SYSTEMTIME *sy
)
return
FALSE
;
/* Windows returns true if the date is valid but outside the limits set */
if
(
DATETIME_IsDateInValidRange
(
infoPtr
,
systime
)
==
FALSE
)
return
TRUE
;
infoPtr
->
dateValid
=
TRUE
;
infoPtr
->
date
=
*
systime
;
/* always store a valid day of week */
...
...
dlls/comctl32/monthcal.c
View file @
c8c3c4be
...
...
@@ -296,7 +296,7 @@ static void MONTHCAL_CopyDate(const SYSTEMTIME *from, SYSTEMTIME *to)
*
* Note that no date validation performed, already validated values expected.
*/
static
LONG
MONTHCAL_CompareSystemTime
(
const
SYSTEMTIME
*
first
,
const
SYSTEMTIME
*
second
)
LONG
MONTHCAL_CompareSystemTime
(
const
SYSTEMTIME
*
first
,
const
SYSTEMTIME
*
second
)
{
FILETIME
ft_first
,
ft_second
;
...
...
dlls/comctl32/tests/datetime.c
View file @
c8c3c4be
...
...
@@ -710,7 +710,7 @@ static void test_dtm_set_and_get_systemtime_with_limits(void)
expect
(
1
,
r
);
r
=
SendMessage
(
hWnd
,
DTM_GETSYSTEMTIME
,
0
,
(
LPARAM
)
&
getSt
[
0
]);
ok
(
r
==
GDT_VALID
,
"Expected %d, not %d(GDT_NONE) or %d(GDT_ERROR), got %ld
\n
"
,
GDT_VALID
,
GDT_NONE
,
GDT_ERROR
,
r
);
todo_wine
expect_systime
(
&
refSt
,
&
getSt
[
0
]);
expect_systime
(
&
refSt
,
&
getSt
[
0
]);
fill_systime_struct
(
&
st
[
0
],
1977
,
1
,
0
,
1
,
0
,
0
,
0
,
0
);
...
...
@@ -718,7 +718,7 @@ static void test_dtm_set_and_get_systemtime_with_limits(void)
expect
(
1
,
r
);
r
=
SendMessage
(
hWnd
,
DTM_GETSYSTEMTIME
,
0
,
(
LPARAM
)
&
getSt
[
0
]);
ok
(
r
==
GDT_VALID
,
"Expected %d, not %d(GDT_NONE) or %d(GDT_ERROR), got %ld
\n
"
,
GDT_VALID
,
GDT_NONE
,
GDT_ERROR
,
r
);
todo_wine
expect_systime
(
&
refSt
,
&
getSt
[
0
]);
expect_systime
(
&
refSt
,
&
getSt
[
0
]);
ok_sequence
(
sequences
,
DATETIME_SEQ_INDEX
,
test_dtm_set_and_get_systime_with_limits
,
"test_dtm_set_and_get_systime_with_limits"
,
FALSE
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment