From 287722b3a3a0fa7b4b951e2cdeafd08792a8c300 Mon Sep 17 00:00:00 2001
From: Konstantin Osipov <kostja@tarantool.org>
Date: Wed, 21 May 2014 21:28:11 +0400
Subject: [PATCH] Simplify the check for length padding in iproto protocol
 parser.

---
 src/iproto.cc | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/src/iproto.cc b/src/iproto.cc
index 138a16f3de..8f0802492e 100644
--- a/src/iproto.cc
+++ b/src/iproto.cc
@@ -469,24 +469,16 @@ 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:
+error:
 			tnt_raise(ClientError, ER_INVALID_MSGPACK,
 				  "packet length");
 		}
 		if (mp_check_uint(pos, in->end) >= 0)
 			break;
 		uint32_t len = mp_decode_uint(&pos);
-
-		/*
-		 * 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;
-		}
+		/* Skip optional request padding. */
+		if (mp_typeof(*pos) == MP_STR && mp_check(&pos, in->end))
+			goto error;
 
 		const char *reqend = pos + len;
 		if (reqend > in->end)
-- 
GitLab