diff --git a/src/iproto.cc b/src/iproto.cc index 560762dcd8bd9d220887bb3709a64c530316a210..83fa53b011ae36a015722706102106f80b72e5e2 100644 --- a/src/iproto.cc +++ b/src/iproto.cc @@ -490,6 +490,7 @@ iproto_enqueue_batch(struct iproto_connection *con, struct ibuf *in) const char *pos = reqstart; /* Read request length. */ if (mp_typeof(*pos) != MP_UINT) { +invalid_length: tnt_raise(IllegalParams, "Invalid MsgPack - packet length"); } @@ -497,7 +498,17 @@ iproto_enqueue_batch(struct iproto_connection *con, struct ibuf *in) break; uint32_t len = mp_decode_uint(&pos); - /* Skip fixheader */ + /* + * A hack to support padding after packet length. + */ + ptrdiff_t need_bytes = IPROTO_FIXHEADER_SIZE - (pos - reqstart); + if (need_bytes > 0 && mp_typeof(*pos) == MP_STR) { + uint32_t padding; + mp_decode_str(&pos, &padding); + if (padding + 1 != need_bytes) + goto invalid_length; + } + const char *reqend = pos + len; if (reqend > in->end) break;