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
75b31d74
Unverified
Commit
75b31d74
authored
Nov 17, 2016
by
Bouke van der Bijl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix segfault on method call with exactly 127 arguments
Reported by
https://hackerone.com/dkasak
parent
a630c4f4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
3 deletions
+22
-3
mrbgems/mruby-compiler/core/codegen.c
mrbgems/mruby-compiler/core/codegen.c
+5
-3
test/t/codegen.rb
test/t/codegen.rb
+17
-0
No files found.
mrbgems/mruby-compiler/core/codegen.c
View file @
75b31d74
...
@@ -772,6 +772,8 @@ attrsym(codegen_scope *s, mrb_sym a)
...
@@ -772,6 +772,8 @@ attrsym(codegen_scope *s, mrb_sym a)
return
mrb_intern
(
s
->
mrb
,
name2
,
len
+
1
);
return
mrb_intern
(
s
->
mrb
,
name2
,
len
+
1
);
}
}
#define CALL_MAXARGS 127
static
int
static
int
gen_values
(
codegen_scope
*
s
,
node
*
t
,
int
val
)
gen_values
(
codegen_scope
*
s
,
node
*
t
,
int
val
)
{
{
...
@@ -780,7 +782,9 @@ gen_values(codegen_scope *s, node *t, int val)
...
@@ -780,7 +782,9 @@ gen_values(codegen_scope *s, node *t, int val)
while
(
t
)
{
while
(
t
)
{
is_splat
=
(
intptr_t
)
t
->
car
->
car
==
NODE_SPLAT
;
/* splat mode */
is_splat
=
(
intptr_t
)
t
->
car
->
car
==
NODE_SPLAT
;
/* splat mode */
if
(
n
>=
127
||
is_splat
)
{
if
(
n
>=
CALL_MAXARGS
-
1
/* need to subtract one because vm.c expects an array if n == CALL_MAXARGS */
||
is_splat
)
{
if
(
val
)
{
if
(
val
)
{
if
(
is_splat
&&
n
==
0
&&
(
intptr_t
)
t
->
car
->
cdr
->
car
==
NODE_ARRAY
)
{
if
(
is_splat
&&
n
==
0
&&
(
intptr_t
)
t
->
car
->
cdr
->
car
==
NODE_ARRAY
)
{
codegen
(
s
,
t
->
car
->
cdr
,
VAL
);
codegen
(
s
,
t
->
car
->
cdr
,
VAL
);
...
@@ -831,8 +835,6 @@ gen_values(codegen_scope *s, node *t, int val)
...
@@ -831,8 +835,6 @@ gen_values(codegen_scope *s, node *t, int val)
return
n
;
return
n
;
}
}
#define CALL_MAXARGS 127
static
void
static
void
gen_call
(
codegen_scope
*
s
,
node
*
tree
,
mrb_sym
name
,
int
sp
,
int
val
,
int
safe
)
gen_call
(
codegen_scope
*
s
,
node
*
tree
,
mrb_sym
name
,
int
sp
,
int
val
,
int
safe
)
{
{
...
...
test/t/codegen.rb
0 → 100644
View file @
75b31d74
##
# Codegen tests
assert
(
'method call with exactly 127 arguments'
)
do
def
args_to_ary
(
*
args
)
args
end
assert_equal
[
0
]
*
127
,
args_to_ary
(
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
\
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
\
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
\
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
\
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
\
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
)
end
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