From a219e258d34a17b509a2e42cbc0f68ba0540b465 Mon Sep 17 00:00:00 2001 From: Leonid Vasiliev <lvasiliev@tarantool.org> Date: Sun, 19 Apr 2020 20:26:18 +0300 Subject: [PATCH] error: fix iproto error stack overlapped by old error 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 1b3f3f9d15..06473a8bc1 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); -- GitLab