mruby-pack: unpack "b/B" should limit result size

This commit is contained in:
Yukihiro "Matz" Matsumoto
2023-10-03 23:39:20 +09:00
parent 861f8bdfa9
commit 097681b4d4
+1 -1
View File
@@ -921,7 +921,7 @@ unpack_bstr(mrb_state *mrb, const void *src, int slen, mrb_value ary, int count,
const char *sptr0 = (const char*)src;
const char *sptr = sptr0;
if (count == -1)
if (count == -1 || count > slen * 8)
count = slen * 8;
mrb_value dst = mrb_str_new(mrb, NULL, count);