Skip to content

Commit

Permalink
Fix size packing/unpacking for EXT 8/16/32
Browse files Browse the repository at this point in the history
For EXT 8/16/32, the "size" field was being incremented by 1 to account for the
type field, but according to the specification the size should only consider the
length of the data field.
  • Loading branch information
tarruda committed Sep 15, 2014
1 parent 0335df5 commit d6122b4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 0 additions & 1 deletion include/msgpack/pack_template.h
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,6 @@ msgpack_pack_inline_func(_ext)(msgpack_pack_user x, size_t l, int8_t type)
msgpack_pack_append_buffer(x, buf, 2);
} break;
default:
l += 1;
if(l < 256) {
char buf[3];
buf[0] = 0xc7;
Expand Down
6 changes: 3 additions & 3 deletions include/msgpack/unpack_template.h
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ msgpack_unpack_func(int, _execute)(msgpack_unpack_struct(_context)* ctx, const c
case CS_BIN_8:
again_fixed_trail_if_zero(ACS_BIN_VALUE, *(uint8_t*)n, _bin_zero);
case CS_EXT_8:
again_fixed_trail_if_zero(ACS_EXT_VALUE, *(uint8_t*)n, _ext_zero);
again_fixed_trail_if_zero(ACS_EXT_VALUE, (*(uint8_t*)n) + 1, _ext_zero);
case CS_STR_16:{
uint16_t tmp;
_msgpack_load16(uint16_t,n,&tmp);
Expand All @@ -338,7 +338,7 @@ msgpack_unpack_func(int, _execute)(msgpack_unpack_struct(_context)* ctx, const c
case CS_EXT_16:{
uint16_t tmp;
_msgpack_load16(uint16_t,n,&tmp);
again_fixed_trail_if_zero(ACS_EXT_VALUE, tmp, _ext_zero);
again_fixed_trail_if_zero(ACS_EXT_VALUE, tmp + 1, _ext_zero);
}
case CS_STR_32:{
uint32_t tmp;
Expand All @@ -353,7 +353,7 @@ msgpack_unpack_func(int, _execute)(msgpack_unpack_struct(_context)* ctx, const c
case CS_EXT_32:{
uint32_t tmp;
_msgpack_load32(uint32_t,n,&tmp);
again_fixed_trail_if_zero(ACS_EXT_VALUE, tmp, _ext_zero);
again_fixed_trail_if_zero(ACS_EXT_VALUE, tmp + 1, _ext_zero);
}
case ACS_STR_VALUE:
_str_zero:
Expand Down

0 comments on commit d6122b4

Please # to comment.