Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ext/msgpack/unpacker.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ void msgpack_unpacker_static_destroy(void)
msgpack_rmem_destroy(&s_stack_rmem);
}

#define HEAD_BYTE_REQUIRED 0xc1
/* outside 0..255 so it never collides with a real byte, including the invalid 0xc1 */
#define HEAD_BYTE_REQUIRED 0x100

static inline bool _msgpack_unpacker_stack_init(msgpack_unpacker_stack_t *stack) {
if (!stack->data) {
Expand Down
28 changes: 28 additions & 0 deletions spec/cruby/unpacker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,33 @@
unpacker.skip
}.should raise_error(MessagePack::MalformedFormatError)
end

it 'skip_nil keeps invalid byte' do
unpacker.feed("\xc1\x01")
unpacker.skip_nil.should == false
lambda {
unpacker.read
}.should raise_error(MessagePack::MalformedFormatError)
end

it 'read_array_header keeps invalid byte' do
unpacker.feed("\xc1\x01")
lambda {
unpacker.read_array_header
}.should raise_error(MessagePack::UnpackError)
lambda {
unpacker.read
}.should raise_error(MessagePack::MalformedFormatError)
end

it 'read_map_header keeps invalid byte' do
unpacker.feed("\xc1\x01")
lambda {
unpacker.read_map_header
}.should raise_error(MessagePack::UnpackError)
lambda {
unpacker.read
}.should raise_error(MessagePack::MalformedFormatError)
end
end

Loading