mruby-pack/pack.c (read_tmpl): check integer overflow before casting.

This commit is contained in:
Yukihiro "Matz" Matsumoto
2022-11-10 22:21:12 +09:00
parent 3b56332952
commit 9fcfd01f20
+1 -1
View File
@@ -1306,7 +1306,7 @@ alias:
if (ISDIGIT(ch)) {
char *e;
mrb_int n;
if (!mrb_read_int(tptr+tmpl->idx, tptr+tlen, &e, &n)) {
if (!mrb_read_int(tptr+tmpl->idx, tptr+tlen, &e, &n) || INT_MAX < n) {
mrb_raise(mrb, E_RUNTIME_ERROR, "too big template length");
}
count = (int)n;