summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-pack
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2021-06-06 08:01:58 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2021-06-06 08:01:58 +0900
commite112c4628168a8ac1069e38b02ceec15b6ab277c (patch)
treeeb9fd4399421cb2b0abdb18aa613674ef421707e /mrbgems/mruby-pack
parentd518294f2076f3a2cb52996d7fc62aef7b56658e (diff)
downloadmruby-e112c4628168a8ac1069e38b02ceec15b6ab277c.tar.gz
mruby-e112c4628168a8ac1069e38b02ceec15b6ab277c.zip
pack.c: check overflow before calling `pack_x`.
Diffstat (limited to 'mrbgems/mruby-pack')
-rw-r--r--mrbgems/mruby-pack/src/pack.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/mrbgems/mruby-pack/src/pack.c b/mrbgems/mruby-pack/src/pack.c
index 17009ee6a..6da0a2c67 100644
--- a/mrbgems/mruby-pack/src/pack.c
+++ b/mrbgems/mruby-pack/src/pack.c
@@ -1191,8 +1191,8 @@ mrb_pack_pack(mrb_state *mrb, mrb_value ary)
if (dir == PACK_DIR_INVALID)
continue;
else if (dir == PACK_DIR_NUL) {
+ if (count > 0 && ridx > INT_MAX - count) goto overflow;
ridx += pack_x(mrb, mrb_nil_value(), result, ridx, count, flags);
- if (ridx < 0) goto overflow;
continue;
}