msgpack 1.8.4 → 1.8.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4a5aa259ac95b61218c0f1cf10a23195bf3c847c7b1423172f50ece723363905
4
- data.tar.gz: 9b3369d91349618e125cef788f3051fd706bcbbf01a78ed2afcb82ecd6d0ecf5
3
+ metadata.gz: 9a5462dff41bc8885570f42b59092d6e02729500a9a873aa15ead68ed8872ccb
4
+ data.tar.gz: 3fcc99b85b8ece0dd0158f2ee511784a789f41ab9d3bafd9f6fc006ccd3b9061
5
5
  SHA512:
6
- metadata.gz: 9feed41442045775173abfcae2d384b27904c44b81cd3674dfa18bfbf10558c9f77ea2f2ed51b694101a33e37761fa94553108fedb866d4834bbce697f96579a
7
- data.tar.gz: ae0d30ca66f5f4e1e22fcfee2615bd91db00ddfe101e043a0753e32bc7252c42d9bbfc3b763d3a519f20fdbb28ad0be2f5071472ad8b7c6c4053ac7702875432
6
+ metadata.gz: 3cb8969960d3d2de3beb39503cb33259ac169f27397d75f981a2563bf14700e4359ca30f2fc6357bf848b707546dc0c692385250c186496e2ef7d5546809bab3
7
+ data.tar.gz: 5cb7b9154e12839ee504c5630d3cee504558206ea63fb54236fc7433191a763267a7fce29a43157d59507f0cc1d4b5b88ba62607571ce98ca1175aa911c1c338
data/ChangeLog CHANGED
@@ -1,3 +1,10 @@
1
+ 2026-09-11 1.8.5
2
+
3
+ * Prevent stack depth underflow when skipping from recursive unpacker.
4
+ * Fix `Unpacker#skip_nil` to properly consume the buffer.
5
+ * Fix some small difference in Factory registration of the Java implementation.
6
+ * Fix some Factory/ext_type optimization edge cases.
7
+
1
8
  2026-07-28 1.8.4
2
9
 
3
10
  * Fix `MessagePack::Buffer` to stop using already released memory page.
@@ -59,6 +59,7 @@ public class Factory extends RubyObject {
59
59
  Factory clone = (Factory)super.dup();
60
60
  clone.extensionRegistry = extensionRegistry();
61
61
  clone.hasSymbolExtType = hasSymbolExtType;
62
+ clone.hasBigIntExtType = hasBigIntExtType;
62
63
  return clone;
63
64
  }
64
65
 
@@ -110,8 +111,8 @@ public class Factory extends RubyObject {
110
111
 
111
112
  extensionRegistry.put(extModule, (int) typeId, recursive, packerProc, unpackerProc);
112
113
 
113
- if (extModule == runtime.getSymbol() && !packerProc.isNil()) {
114
- hasSymbolExtType = true;
114
+ if (extModule == runtime.getSymbol()) {
115
+ hasSymbolExtType = packerProc != null && !packerProc.isNil();
115
116
  }
116
117
 
117
118
  if (options != null) {
@@ -122,6 +123,8 @@ public class Factory extends RubyObject {
122
123
  } else {
123
124
  throw runtime.newArgumentError("oversized_integer_extension: true is only for Integer class");
124
125
  }
126
+ } else if (extModule == runtime.getModule("Integer")) {
127
+ hasBigIntExtType = false;
125
128
  }
126
129
  }
127
130
 
@@ -121,7 +121,10 @@ static VALUE Factory_dup(VALUE self)
121
121
  msgpack_factory_t *fc = Factory_get(self);
122
122
  msgpack_factory_t *cloned_fc = Factory_get(clone);
123
123
 
124
+ cloned_fc->has_bigint_ext_type = fc->has_bigint_ext_type;
124
125
  cloned_fc->has_symbol_ext_type = fc->has_symbol_ext_type;
126
+ cloned_fc->optimized_symbol_ext_type = fc->optimized_symbol_ext_type;
127
+ cloned_fc->symbol_ext_type = fc->symbol_ext_type;
125
128
  cloned_fc->pkrg = fc->pkrg;
126
129
  msgpack_unpacker_ext_registry_borrow(fc->ukrg, &cloned_fc->ukrg);
127
130
  msgpack_packer_ext_registry_dup(clone, &fc->pkrg, &cloned_fc->pkrg);
@@ -230,12 +233,13 @@ static VALUE Factory_register_type_internal(VALUE self, VALUE rb_ext_type, VALUE
230
233
  }
231
234
 
232
235
  if(ext_module == rb_cSymbol) {
233
- if(NIL_P(options) || RTEST(rb_hash_aref(options, ID2SYM(rb_intern("packer"))))) {
234
- fc->has_symbol_ext_type = true;
235
- }
236
- if(RTEST(options) && RTEST(rb_hash_aref(options, ID2SYM(rb_intern("optimized_symbols_parsing"))))) {
237
- fc->optimized_symbol_ext_type = true;
238
- }
236
+ fc->symbol_ext_type = ext_type;
237
+ fc->has_symbol_ext_type = NIL_P(options) || RTEST(packer_proc);
238
+ fc->optimized_symbol_ext_type = RTEST(options) && RTEST(rb_hash_aref(options, ID2SYM(rb_intern("optimized_symbols_parsing"))));
239
+ }
240
+
241
+ if(ext_module == rb_cInteger) {
242
+ fc->has_bigint_ext_type = false;
239
243
  }
240
244
 
241
245
  if(RTEST(options)) {
@@ -246,7 +250,6 @@ static VALUE Factory_register_type_internal(VALUE self, VALUE rb_ext_type, VALUE
246
250
  rb_raise(rb_eArgError, "oversized_integer_extension: true is only for Integer class");
247
251
  }
248
252
  }
249
-
250
253
  if(RTEST(rb_hash_aref(options, ID2SYM(rb_intern("recursive"))))) {
251
254
  flags |= MSGPACK_EXT_RECURSIVE;
252
255
  }
@@ -235,7 +235,7 @@ static VALUE Packer_write_extension(VALUE self, VALUE obj)
235
235
 
236
236
  VALUE rb_ext_type = RSTRUCT_GET(obj, 0);
237
237
  if(!RB_TYPE_P(rb_ext_type, T_FIXNUM)) {
238
- rb_raise(rb_eRangeError, "integer %s too big to convert to `signed char'", RSTRING_PTR(rb_String(rb_ext_type)));
238
+ rb_raise(rb_eRangeError, "integer %"PRIsVALUE" too big to convert to `signed char'", rb_ext_type);
239
239
  }
240
240
 
241
241
  int ext_type = FIX2INT(rb_ext_type);
@@ -386,9 +386,15 @@ static inline int read_raw_body_begin(msgpack_unpacker_t* uk, int raw_type)
386
386
  * instead of raising StackError like every other container type. */
387
387
  return PRIMITIVE_STACK_TOO_DEEP;
388
388
  }
389
+ size_t barrier_depth = uk->stack.depth;
389
390
  int raised;
390
391
  obj = protected_proc_call(proc, 1, &uk->self, &raised);
391
- msgpack_unpacker_stack_pop(uk);
392
+
393
+ /* The user proc can drive the unpacker itself (Unpacker#read, #skip,
394
+ * or a rescued error) and leave stack.depth anywhere, including 0.
395
+ * Restore it to just below the barrier we pushed instead of an
396
+ * unconditional decrement, which would underflow to SIZE_MAX. */
397
+ uk->stack.depth = barrier_depth - 1;
392
398
 
393
399
  if (raised) {
394
400
  uk->last_object = rb_errinfo();
@@ -911,8 +917,8 @@ int msgpack_unpacker_skip_nil(msgpack_unpacker_t* uk)
911
917
  return b;
912
918
  }
913
919
  if(b == 0xc0) {
920
+ reset_head_byte(uk);
914
921
  return 1;
915
922
  }
916
923
  return 0;
917
924
  }
918
-
@@ -14,10 +14,12 @@ module MessagePack
14
14
  options[:packer] = packer.to_sym.to_proc
15
15
  when Method
16
16
  options[:packer] = packer.to_proc
17
- when packer.respond_to?(:call)
18
- options[:packer] = packer.method(:call).to_proc
19
17
  else
20
- raise ::TypeError, "expected :packer argument to be a callable object, got: #{packer.inspect}"
18
+ if packer.respond_to?(:call)
19
+ options[:packer] = packer.method(:call).to_proc
20
+ else
21
+ raise ::TypeError, "expected :packer argument to be a callable object, got: #{packer.inspect}"
22
+ end
21
23
  end
22
24
 
23
25
  case unpacker = options[:unpacker]
@@ -27,10 +29,12 @@ module MessagePack
27
29
  options[:unpacker] = klass.method(unpacker).to_proc
28
30
  when Method
29
31
  options[:unpacker] = unpacker.to_proc
30
- when packer.respond_to?(:call)
31
- options[:unpacker] = unpacker.method(:call).to_proc
32
32
  else
33
- raise ::TypeError, "expected :unpacker argument to be a callable object, got: #{unpacker.inspect}"
33
+ if unpacker.respond_to?(:call)
34
+ options[:unpacker] = unpacker.method(:call).to_proc
35
+ else
36
+ raise ::TypeError, "expected :unpacker argument to be a callable object, got: #{unpacker.inspect}"
37
+ end
34
38
  end
35
39
  end
36
40
 
@@ -51,7 +55,7 @@ module MessagePack
51
55
  type = ary[0]
52
56
  packer_proc = ary[1]
53
57
  unpacker_proc = nil
54
- if unpacker.has_key?(type)
58
+ if unpacker.has_key?(type) && unpacker[type][0] == klass
55
59
  unpacker_proc = unpacker.delete(type)[1]
56
60
  end
57
61
  list << {type: type, class: klass, packer: packer_proc, unpacker: unpacker_proc}
@@ -85,7 +89,7 @@ module MessagePack
85
89
 
86
90
  def type_registered?(klass_or_type, selector=:both)
87
91
  case klass_or_type
88
- when Class
92
+ when Module
89
93
  klass = klass_or_type
90
94
  registered_types(selector).any?{|entry| klass <= entry[:class] }
91
95
  when Integer
@@ -23,7 +23,7 @@ module MessagePack
23
23
 
24
24
  def type_registered?(klass_or_type)
25
25
  case klass_or_type
26
- when Class
26
+ when Module
27
27
  klass = klass_or_type
28
28
  registered_types.any?{|entry| klass <= entry[:class] }
29
29
  when Integer
@@ -27,7 +27,7 @@ module MessagePack
27
27
 
28
28
  def type_registered?(klass_or_type)
29
29
  case klass_or_type
30
- when Class
30
+ when Module
31
31
  klass = klass_or_type
32
32
  registered_types.any?{|entry| klass == entry[:class] }
33
33
  when Integer
@@ -1,5 +1,5 @@
1
1
  module MessagePack
2
- VERSION = "1.8.4"
2
+ VERSION = "1.8.5"
3
3
  # Note for maintainers:
4
4
  # Don't miss building/releasing the JRuby version (rake buld:java)
5
5
  # See "How to build -java rubygems" in README for more details.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: msgpack
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.4
4
+ version: 1.8.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sadayuki Furuhashi