Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
25b23a09
Commit
25b23a09
authored
Sep 07, 2004
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid integer overflows in NTDLL_get_server_timeout (spotted by Mike
McCormack).
parent
c13638ee
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
9 deletions
+27
-9
time.c
dlls/ntdll/time.c
+27
-9
No files found.
dlls/ntdll/time.c
View file @
25b23a09
...
...
@@ -28,6 +28,7 @@
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <time.h>
#ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
...
...
@@ -296,6 +297,8 @@ static const struct tagTZ_INFO TZ_INFO[] =
/* 1601 to 1980 is 379 years plus 91 leap days */
#define SECS_1601_TO_1980 ((379 * 365 + 91) * (ULONGLONG)SECSPERDAY)
#define TICKS_1601_TO_1980 (SECS_1601_TO_1980 * TICKSPERSEC)
/* max ticks that can be represented as Unix time */
#define TICKS_1601_TO_UNIX_MAX ((SECS_1601_TO_1970 + INT_MAX) * TICKSPERSEC)
static
const
int
MonthLengths
[
2
][
MONSPERYEAR
]
=
...
...
@@ -337,20 +340,35 @@ void NTDLL_get_server_timeout( abs_time_t *when, const LARGE_INTEGER *timeout )
else
if
(
timeout
->
QuadPart
<=
0
)
/* relative timeout */
{
struct
timeval
tv
;
ULONG
sec
=
RtlEnlargedUnsignedDivide
(
-
timeout
->
QuadPart
,
TICKSPERSEC
,
&
remainder
);
gettimeofday
(
&
tv
,
0
);
when
->
sec
=
tv
.
tv_sec
+
sec
;
if
((
when
->
usec
=
tv
.
tv_usec
+
(
remainder
/
10
))
>=
1000000
)
if
(
-
timeout
->
QuadPart
>
(
LONGLONG
)
INT_MAX
*
TICKSPERSEC
)
when
->
sec
=
when
->
usec
=
INT_MAX
;
else
{
when
->
usec
-=
1000000
;
when
->
sec
++
;
ULONG
sec
=
RtlEnlargedUnsignedDivide
(
-
timeout
->
QuadPart
,
TICKSPERSEC
,
&
remainder
);
gettimeofday
(
&
tv
,
0
);
when
->
sec
=
tv
.
tv_sec
+
sec
;
if
((
when
->
usec
=
tv
.
tv_usec
+
(
remainder
/
10
))
>=
1000000
)
{
when
->
usec
-=
1000000
;
when
->
sec
++
;
}
if
(
when
->
sec
<
tv
.
tv_sec
)
/* overflow */
when
->
sec
=
when
->
usec
=
INT_MAX
;
}
}
else
/* absolute time */
{
when
->
sec
=
RtlEnlargedUnsignedDivide
(
timeout
->
QuadPart
-
TICKS_1601_TO_1970
,
TICKSPERSEC
,
&
remainder
);
when
->
usec
=
remainder
/
10
;
if
(
timeout
->
QuadPart
<
TICKS_1601_TO_1970
)
when
->
sec
=
when
->
usec
=
0
;
else
if
(
timeout
->
QuadPart
>
TICKS_1601_TO_UNIX_MAX
)
when
->
sec
=
when
->
usec
=
INT_MAX
;
else
{
when
->
sec
=
RtlEnlargedUnsignedDivide
(
timeout
->
QuadPart
-
TICKS_1601_TO_1970
,
TICKSPERSEC
,
&
remainder
);
when
->
usec
=
remainder
/
10
;
}
}
}
...
...
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