msgpack-ruby icon indicating copy to clipboard operation
msgpack-ruby copied to clipboard

Unpacker#read_array_header and Unpacker#read_map_header return a wrong size.

Open x-nagasawa opened this issue 7 years ago • 1 comments

In windows environment with msgpack-1.0.2-x86-mingw32, Unpacker#read_array_header for array16 and Unpacker#read_map_header for map16 return a wrong size.

A code to reproduce is following.

require 'msgpack'

p MessagePack::VERSION

unpacker = MessagePack::Unpacker.new()
# feed array 16 including one element.
unpacker.feed("\xdc\x00\x01\x01")
# expect "1" but returns "10001"
puts 'read_array_header : ' + unpacker.read_array_header.to_s(16)
unpacker.read.to_s
# feed map 16 including one element.
unpacker.feed("\xde\x00\x02\x01\x02\x03\x04")
# expect "2" but returns "20002"
puts 'read_map_header : ' + unpacker.read_map_header.to_s(16)

In Windows7(64bit) with ruby 2.2.1p85 (2015-02-26 revision 49769) [i386-mingw32], the code returns wrong size as below.

"1.0.2" read_array_header : 10001 read_map_header : 20002

The result of read_array_header is excepted "1" but it returns "0x010001". The result of read_map_header is excepted "2" but it returns "0x020002".

I guess there are some type-cast or bit-mask miss.

In Linux(CentOS7) with ruby 2.0.0p598 [x86_64-linux], it works correctly.

"1.0.2" read_array_header : 1 read_map_header : 2

x-nagasawa avatar Nov 24 '16 03:11 x-nagasawa

In windows environment

The current maintainers are extremely unlikely to be able to even triage this any time soon - sorry.

chrisseaton avatar Jul 19 '22 19:07 chrisseaton