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
9b9c41d6
Unverified
Commit
9b9c41d6
authored
Apr 12, 2019
by
Yukihiro "Matz" Matsumoto
Committed by
GitHub
Apr 12, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4371 from clayton-shopify/fix-buffer-overflows
Fix buffer overflows in parser.
parents
9c252410
57e61762
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
12 deletions
+15
-12
mrbgems/mruby-compiler/core/parse.y
mrbgems/mruby-compiler/core/parse.y
+15
-12
No files found.
mrbgems/mruby-compiler/core/parse.y
View file @
9b9c41d6
...
@@ -3716,8 +3716,9 @@ yyerror_c(parser_state *p, const char *msg, char c)
...
@@ -3716,8 +3716,9 @@ yyerror_c(parser_state *p, const char *msg, char c)
{
{
char buf[256];
char buf[256];
strcpy(buf, msg);
strncpy(buf, msg, sizeof(buf) - 2);
strcat(buf, &c);
buf[sizeof(buf) - 2] = '\0';
strncat(buf, &c, 1);
yyerror(p, buf);
yyerror(p, buf);
}
}
...
@@ -3760,9 +3761,10 @@ yywarning_s(parser_state *p, const char *msg, const char *s)
...
@@ -3760,9 +3761,10 @@ yywarning_s(parser_state *p, const char *msg, const char *s)
{
{
char buf[256];
char buf[256];
strcpy(buf, msg);
strncpy(buf, msg, sizeof(buf) - 1);
strcat(buf, ": ");
buf[sizeof(buf) - 1] = '\0';
strcat(buf, s);
strncat(buf, ": ", sizeof(buf) - strlen(buf) - 1);
strncat(buf, s, sizeof(buf) - strlen(buf) - 1);
yywarning(p, buf);
yywarning(p, buf);
}
}
...
@@ -4326,11 +4328,12 @@ parse_string(parser_state *p)
...
@@ -4326,11 +4328,12 @@ parse_string(parser_state *p)
if (sizeof(s1)+sizeof(s2)+strlen(hinf->term)+1 >= sizeof(buf)) {
if (sizeof(s1)+sizeof(s2)+strlen(hinf->term)+1 >= sizeof(buf)) {
yyerror(p, "can't find heredoc delimiter anywhere before EOF");
yyerror(p, "can't find heredoc delimiter anywhere before EOF");
} else {
strcpy(buf, s1);
strcat(buf, hinf->term);
strcat(buf, s2);
yyerror(p, buf);
}
}
strcpy(buf, s1);
strcat(buf, hinf->term);
strcat(buf, s2);
yyerror(p, buf);
return 0;
return 0;
}
}
pylval.nd = new_str(p, tok(p), toklen(p));
pylval.nd = new_str(p, tok(p), toklen(p));
...
@@ -4487,7 +4490,7 @@ parse_string(parser_state *p)
...
@@ -4487,7 +4490,7 @@ parse_string(parser_state *p)
strcat(msg, "s");
strcat(msg, "s");
}
}
strcat(msg, " - ");
strcat(msg, " - ");
str
cat(msg, tok(p)
);
str
ncat(msg, tok(p), sizeof(msg) - strlen(msg) - 1
);
yyerror(p, msg);
yyerror(p, msg);
}
}
if (f != 0) {
if (f != 0) {
...
@@ -4918,7 +4921,7 @@ parser_yylex(parser_state *p)
...
@@ -4918,7 +4921,7 @@ parser_yylex(parser_state *p)
char cc = (char)c2;
char cc = (char)c2;
strcpy(buf, "invalid character syntax; use ?\\");
strcpy(buf, "invalid character syntax; use ?\\");
str
cat(buf, &cc
);
str
ncat(buf, &cc, 1
);
yyerror(p, buf);
yyerror(p, buf);
}
}
}
}
...
@@ -6147,7 +6150,7 @@ mrb_load_exec(mrb_state *mrb, struct mrb_parser_state *p, mrbc_context *c)
...
@@ -6147,7 +6150,7 @@ mrb_load_exec(mrb_state *mrb, struct mrb_parser_state *p, mrbc_context *c)
strcpy(buf, "line ");
strcpy(buf, "line ");
dump_int(p->error_buffer[0].lineno, buf+5);
dump_int(p->error_buffer[0].lineno, buf+5);
strcat(buf, ": ");
strcat(buf, ": ");
str
cat(buf, p->error_buffer[0].message
);
str
ncat(buf, p->error_buffer[0].message, sizeof(buf) - strlen(buf) - 1
);
mrb->exc = mrb_obj_ptr(mrb_exc_new(mrb, E_SYNTAX_ERROR, buf, strlen(buf)));
mrb->exc = mrb_obj_ptr(mrb_exc_new(mrb, E_SYNTAX_ERROR, buf, strlen(buf)));
mrb_parser_free(p);
mrb_parser_free(p);
return mrb_undef_value();
return mrb_undef_value();
...
...
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