From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp49.i.mail.ru (smtp49.i.mail.ru [94.100.177.109]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id BF74A4696C5 for ; Mon, 20 Apr 2020 01:25:22 +0300 (MSK) From: Leonid Vasiliev Date: Mon, 20 Apr 2020 01:25:12 +0300 Message-Id: In-Reply-To: References: In-Reply-To: References: Subject: [Tarantool-patches] [PATCH V6 10/10] error: fix iproto error stack overlapped by old error List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: v.shpilevoy@tarantool.org, alexander.turenko@tarantool.org Cc: tarantool-patches@dev.tarantool.org Fix possible overlap of IPROTO_ERROR by IPROTO_ERROR_24. This was possible because messages are transmitted in a map and an order is not defined. IPROTO_ERROR_24 could be parsed after the IPROTO_ERROR, and could throw it away. --- src/box/xrow.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/box/xrow.c b/src/box/xrow.c index 1b3f3f9..06473a8 100644 --- a/src/box/xrow.c +++ b/src/box/xrow.c @@ -1102,6 +1102,7 @@ xrow_decode_error(struct xrow_header *row) if (mp_typeof(*pos) != MP_MAP) goto error; map_size = mp_decode_map(&pos); + bool is_stack_parsed = false; for (uint32_t i = 0; i < map_size; i++) { if (mp_typeof(*pos) != MP_UINT) { mp_next(&pos); /* key */ @@ -1117,12 +1118,15 @@ xrow_decode_error(struct xrow_header *row) */ uint32_t len; const char *str = mp_decode_str(&pos, &len); - snprintf(error, sizeof(error), "%.*s", len, str); - box_error_set(__FILE__, __LINE__, code, error); + if (!is_stack_parsed) { + snprintf(error, sizeof(error), "%.*s", len, str); + box_error_set(__FILE__, __LINE__, code, error); + } } else if (key == IPROTO_ERROR) { struct error *e = error_unpack_unsafe(&pos); if (e == NULL) goto error; + is_stack_parsed = true; diag_set_error(diag_get(), e); } else { mp_next(&pos); -- 2.7.4