Skip to content

Commit

Permalink
Check overflow string length
Browse files Browse the repository at this point in the history
Fix #3360
  • Loading branch information
ksss committed Dec 23, 2016
1 parent 987daa6 commit c626b82
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,9 @@ mrb_str_concat(mrb_state *mrb, mrb_value self, mrb_value other)
s2 = mrb_str_ptr(other);
len = RSTR_LEN(s1) + RSTR_LEN(s2);

if (len < 0 || len >= MRB_INT_MAX) {
mrb_raise(mrb, E_ARGUMENT_ERROR, "string size too big");
}
if (RSTRING_CAPA(self) < len) {
resize_capa(mrb, s1, len);
}
Expand Down

0 comments on commit c626b82

Please sign in to comment.