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
98c759e8
Commit
98c759e8
authored
Aug 29, 2018
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check the size of rescue&ensure stacks; ref #4088
Those small stack indexes can cause integer overflow.
parent
2a88a546
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
5 deletions
+30
-5
src/vm.c
src/vm.c
+30
-5
No files found.
src/vm.c
View file @
98c759e8
...
...
@@ -1239,11 +1239,24 @@ RETRY_TRY_BLOCK:
}
CASE
(
OP_ONERR
,
S
)
{
/* check rescue stack */
if
(
mrb
->
c
->
ci
->
ridx
==
UINT16_MAX
)
{
mrb_value
exc
=
mrb_exc_new_str_lit
(
mrb
,
E_RUNTIME_ERROR
,
"too many nested rescues"
);
mrb_exc_set
(
mrb
,
exc
);
goto
L_RAISE
;
}
/* expand rescue stack */
if
(
mrb
->
c
->
rsize
<=
mrb
->
c
->
ci
->
ridx
)
{
if
(
mrb
->
c
->
rsize
==
0
)
mrb
->
c
->
rsize
=
RESCUE_STACK_INIT_SIZE
;
else
mrb
->
c
->
rsize
*=
2
;
mrb
->
c
->
rescue
=
(
uint16_t
*
)
mrb_realloc
(
mrb
,
mrb
->
c
->
rescue
,
sizeof
(
uint16_t
)
*
mrb
->
c
->
rsize
);
else
{
mrb
->
c
->
rsize
*=
2
;
if
(
mrb
->
c
->
rsize
<=
mrb
->
c
->
ci
->
ridx
)
{
mrb
->
c
->
rsize
=
UINT16_MAX
;
}
}
mrb
->
c
->
rescue
=
(
uint16_t
*
)
mrb_realloc
(
mrb
,
mrb
->
c
->
rescue
,
sizeof
(
uint16_t
)
*
mrb
->
c
->
rsize
);
}
/* push rescue stack */
mrb
->
c
->
rescue
[
mrb
->
c
->
ci
->
ridx
++
]
=
a
;
NEXT
;
}
...
...
@@ -1292,12 +1305,24 @@ RETRY_TRY_BLOCK:
struct
RProc
*
p
;
p
=
mrb_closure_new
(
mrb
,
irep
->
reps
[
a
]);
/* push ensure_stack */
/* check ensure stack */
if
(
mrb
->
c
->
eidx
==
UINT16_MAX
)
{
mrb_value
exc
=
mrb_exc_new_str_lit
(
mrb
,
E_RUNTIME_ERROR
,
"too many nested ensures"
);
mrb_exc_set
(
mrb
,
exc
);
goto
L_RAISE
;
}
/* expand ensure stack */
if
(
mrb
->
c
->
esize
<=
mrb
->
c
->
eidx
+
1
)
{
if
(
mrb
->
c
->
esize
==
0
)
mrb
->
c
->
esize
=
ENSURE_STACK_INIT_SIZE
;
else
mrb
->
c
->
esize
*=
2
;
mrb
->
c
->
ensure
=
(
struct
RProc
**
)
mrb_realloc
(
mrb
,
mrb
->
c
->
ensure
,
sizeof
(
struct
RProc
*
)
*
mrb
->
c
->
esize
);
else
{
mrb
->
c
->
esize
*=
2
;
if
(
mrb
->
c
->
esize
<=
mrb
->
c
->
eidx
)
{
mrb
->
c
->
esize
=
UINT16_MAX
;
}
}
mrb
->
c
->
ensure
=
(
struct
RProc
**
)
mrb_realloc
(
mrb
,
mrb
->
c
->
ensure
,
sizeof
(
struct
RProc
*
)
*
mrb
->
c
->
esize
);
}
/* push ensure stack */
mrb
->
c
->
ensure
[
mrb
->
c
->
eidx
++
]
=
p
;
mrb
->
c
->
ensure
[
mrb
->
c
->
eidx
]
=
NULL
;
mrb_gc_arena_restore
(
mrb
,
ai
);
...
...
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