mruby-pack: unpack "b/B" should limit result size
authorYukihiro "Matz" Matsumoto <[email protected]>
Tue, 3 Oct 2023 14:39:20 +0000 (3 23:39 +0900)
committerYukihiro "Matz" Matsumoto <[email protected]>
Mon, 9 Oct 2023 13:39:44 +0000 (9 22:39 +0900)
mrbgems/mruby-pack/src/pack.c

index 26c2890..08db909 100644 (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);