mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
pack.c: check overflow before reading count.
This commit is contained in:
@@ -1131,10 +1131,10 @@ alias:
|
||||
if (ISDIGIT(ch)) {
|
||||
count = ch - '0';
|
||||
while (tmpl->idx < tlen && ISDIGIT(tptr[tmpl->idx])) {
|
||||
ch = tptr[tmpl->idx++] - '0';
|
||||
if (count+10 > INT_MAX/10) {
|
||||
mrb_raise(mrb, E_RUNTIME_ERROR, "too big template length");
|
||||
}
|
||||
ch = tptr[tmpl->idx++] - '0';
|
||||
count = count * 10 + ch;
|
||||
}
|
||||
continue; /* special case */
|
||||
|
||||
Reference in New Issue
Block a user