Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass empty string into MessagePack::Unpacker.feed will stop further feeding valid string in version >= 1.7.0 #345

Closed
tung-vu-td opened this issue Jul 12, 2023 · 1 comment · Fixed by #348

Comments

@tung-vu-td
Copy link

tung-vu-td commented Jul 12, 2023

Hi,

Not sure this is a bug, but at least it is a difference between version 1.6.1 and 1.7.0. I figured you guys may want to know.

So if you run the following code, it will output empty array:

gem 'msgpack', '= 1.7.0'
require 'msgpack'
require 'stringio'

def test_string()
  s = StringIO.new(String.new)
  pk = MessagePack::Packer.new(s)
  pk.write('hello').write('world').flush
  s.string
end

result = []
unpacker = MessagePack::Unpacker.new
unpacker.feed("")
unpacker.feed(test_string)
unpacker.each do |row|
  result << row
end

puts "#{result}"

While changing the first line to gem 'msgpack', '= 1.6.1'. The output will be ["hello", "world"]

@casperisfine
Copy link

Thanks, that indeed look like a regression, I'll fix it soon, shouldn't be too hard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants