Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
049ec905
Unverified
Commit
049ec905
authored
Apr 19, 2021
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
time.c: add integer boundary check for year.
On configurations where `sizeof(mrb_int) > sizeof(int)`.
parent
713fb53b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
10 deletions
+17
-10
mrbgems/mruby-time/src/time.c
mrbgems/mruby-time/src/time.c
+17
-10
No files found.
mrbgems/mruby-time/src/time.c
View file @
049ec905
...
...
@@ -461,22 +461,29 @@ time_mktime(mrb_state *mrb, mrb_int ayear, mrb_int amonth, mrb_int aday,
time_t
nowsecs
;
struct
tm
nowtime
=
{
0
};
nowtime
.
tm_year
=
(
int
)
ayear
-
1900
;
nowtime
.
tm_mon
=
(
int
)
amonth
-
1
;
#if MRB_INT_MAX > INT_MAX
#define OUTINT(x) (INT_MIN > (x) || (x) > INT_MAX)
#else
#define OUTINT(x) 0
#endif
if
(
OUTINT
(
ayear
-
1900
)
||
amonth
<
1
||
amonth
>
12
||
aday
<
1
||
aday
>
31
||
ahour
<
0
||
ahour
>
24
||
(
ahour
==
24
&&
(
amin
>
0
||
asec
>
0
))
||
amin
<
0
||
amin
>
59
||
asec
<
0
||
asec
>
60
)
mrb_raise
(
mrb
,
E_ARGUMENT_ERROR
,
"argument out of range"
);
nowtime
.
tm_year
=
(
int
)(
ayear
-
1900
);
nowtime
.
tm_mon
=
(
int
)(
amonth
-
1
);
nowtime
.
tm_mday
=
(
int
)
aday
;
nowtime
.
tm_hour
=
(
int
)
ahour
;
nowtime
.
tm_min
=
(
int
)
amin
;
nowtime
.
tm_sec
=
(
int
)
asec
;
nowtime
.
tm_isdst
=
-
1
;
if
(
nowtime
.
tm_mon
<
0
||
nowtime
.
tm_mon
>
11
||
nowtime
.
tm_mday
<
1
||
nowtime
.
tm_mday
>
31
||
nowtime
.
tm_hour
<
0
||
nowtime
.
tm_hour
>
24
||
(
nowtime
.
tm_hour
==
24
&&
(
nowtime
.
tm_min
>
0
||
nowtime
.
tm_sec
>
0
))
||
nowtime
.
tm_min
<
0
||
nowtime
.
tm_min
>
59
||
nowtime
.
tm_sec
<
0
||
nowtime
.
tm_sec
>
60
)
mrb_raise
(
mrb
,
E_ARGUMENT_ERROR
,
"argument out of range"
);
if
(
timezone
==
MRB_TIMEZONE_UTC
)
{
nowsecs
=
timegm
(
&
nowtime
);
}
...
...
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