Tarantool development patches archive
 help / color / mirror / Atom feed
From: Leonid Vasiliev <lvasiliev@tarantool.org>
To: v.shpilevoy@tarantool.org, alexander.turenko@tarantool.org
Cc: tarantool-patches@dev.tarantool.org
Subject: [Tarantool-patches] [PATCH V6 10/10] error: fix iproto error stack overlapped by old error
Date: Mon, 20 Apr 2020 01:25:12 +0300	[thread overview]
Message-ID: <ecc63349cea14abd07939c3ca8587a703ef44480.1587334824.git.lvasiliev@tarantool.org> (raw)
In-Reply-To: <cover.1587334824.git.lvasiliev@tarantool.org>
In-Reply-To: <cover.1587334824.git.lvasiliev@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

  parent reply	other threads:[~2020-04-19 22:25 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-19 22:25 [Tarantool-patches] [PATCH V6 00/10] Extending error functionality Leonid Vasiliev
2020-04-19 22:25 ` [Tarantool-patches] [PATCH V6 01/10] error: add custom error type Leonid Vasiliev
2020-04-19 22:25 ` [Tarantool-patches] [PATCH V6 02/10] session: add offset to SQL session settings array Leonid Vasiliev
2020-04-19 22:25 ` [Tarantool-patches] [PATCH V6 03/10] error: add session setting for error type marshaling Leonid Vasiliev
2020-04-19 22:25 ` [Tarantool-patches] [PATCH V6 04/10] error: update constructors of some errors Leonid Vasiliev
2020-04-19 22:25 ` [Tarantool-patches] [PATCH V6 05/10] box: move Lua MP_EXT decoder from tuple.c Leonid Vasiliev
2020-04-19 22:25 ` [Tarantool-patches] [PATCH V6 06/10] error: add error MsgPack encoding Leonid Vasiliev
2020-04-19 22:25 ` [Tarantool-patches] [PATCH V6 07/10] error: export error_unref() function Leonid Vasiliev
2020-04-19 22:25 ` [Tarantool-patches] [PATCH V6 08/10] error: make iproto errors reuse mp_error module Leonid Vasiliev
2020-04-19 22:25 ` [Tarantool-patches] [PATCH V6 09/10] iproto: rename IPROTO_ERROR and IPROTO_ERROR_STACK Leonid Vasiliev
2020-04-19 22:25 ` Leonid Vasiliev [this message]
2020-04-20  0:26 ` [Tarantool-patches] [PATCH V6 00/10] Extending error functionality Vladislav Shpilevoy
2020-04-20  8:05   ` lvasiliev
2020-04-20  8:05   ` Kirill Yukhin
2020-04-21 19:03     ` Konstantin Osipov
2020-04-22 16:17       ` lvasiliev
2020-04-22 17:23         ` Konstantin Osipov
2020-04-20  8:30 ` Kirill Yukhin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ecc63349cea14abd07939c3ca8587a703ef44480.1587334824.git.lvasiliev@tarantool.org \
    --to=lvasiliev@tarantool.org \
    --cc=alexander.turenko@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH V6 10/10] error: fix iproto error stack overlapped by old error' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox