Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: tarantool-patches@dev.tarantool.org, alyapunov@tarantool.org,
	korablev@tarantool.org
Subject: [Tarantool-patches] [PATCH 2/2] tuple: fix access by JSON path starting from '[*]'
Date: Wed,  5 Aug 2020 01:45:19 +0200	[thread overview]
Message-ID: <21871bd97383aa16c15d8bdad20775f2a85548ae.1596584571.git.v.shpilevoy@tarantool.org> (raw)
In-Reply-To: <cover.1596584571.git.v.shpilevoy@tarantool.org>

Tuple JSON field access crashed when '[*]' was used as a first
part of the JSON path. The patch makes it treated like 'field not
found'.

Follow-up #5224
---
 src/box/tuple.c                                 | 3 ++-
 test/box/gh-5224-multikey-field-access.result   | 9 +++++++++
 test/box/gh-5224-multikey-field-access.test.lua | 6 ++++++
 3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/src/box/tuple.c b/src/box/tuple.c
index 9f0f24c64..e77753a5b 100644
--- a/src/box/tuple.c
+++ b/src/box/tuple.c
@@ -531,7 +531,8 @@ tuple_field_raw_by_full_path(struct tuple_format *format, const char *tuple,
 		break;
 	}
 	default:
-		assert(token.type == JSON_TOKEN_END);
+		assert(token.type == JSON_TOKEN_END ||
+		       token.type == JSON_TOKEN_ANY);
 		return NULL;
 	}
 	return tuple_field_raw_by_path(format, tuple, field_map, fieldno,
diff --git a/test/box/gh-5224-multikey-field-access.result b/test/box/gh-5224-multikey-field-access.result
index 014e810d0..20df44cc3 100644
--- a/test/box/gh-5224-multikey-field-access.result
+++ b/test/box/gh-5224-multikey-field-access.result
@@ -150,6 +150,15 @@ t['[2][3]']
  | - {'p1': {'p2': 6}}
  | ...
 
+--
+-- Multikey path part could crash when used as a first part of the path during
+-- accessing a tuple field.
+--
+t['[*]']
+ | ---
+ | - null
+ | ...
+
 s:drop()
  | ---
  | ...
diff --git a/test/box/gh-5224-multikey-field-access.test.lua b/test/box/gh-5224-multikey-field-access.test.lua
index 19765171e..6f6691d3c 100644
--- a/test/box/gh-5224-multikey-field-access.test.lua
+++ b/test/box/gh-5224-multikey-field-access.test.lua
@@ -63,4 +63,10 @@ t['[2][3].p1.p2']
 t['[2][3].p1']
 t['[2][3]']
 
+--
+-- Multikey path part could crash when used as a first part of the path during
+-- accessing a tuple field.
+--
+t['[*]']
+
 s:drop()
-- 
2.21.1 (Apple Git-122.3)

  parent reply	other threads:[~2020-08-04 23:45 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-04 23:45 [Tarantool-patches] [PATCH 0/2] JSON field multikey crash Vladislav Shpilevoy
2020-08-04 23:45 ` [Tarantool-patches] [PATCH 1/2] tuple: fix multikey field JSON access crash Vladislav Shpilevoy
2020-08-06 16:00   ` Oleg Babin
2020-08-06 20:04     ` Vladislav Shpilevoy
2020-08-10 16:09   ` Nikita Pettik
2020-08-11  9:44   ` Aleksandr Lyapunov
2020-08-11 21:24     ` Vladislav Shpilevoy
2020-08-12 13:05       ` Aleksandr Lyapunov
2020-08-12 20:34         ` Vladislav Shpilevoy
2020-08-04 23:45 ` Vladislav Shpilevoy [this message]
2020-08-10 17:52   ` [Tarantool-patches] [PATCH 2/2] tuple: fix access by JSON path starting from '[*]' Nikita Pettik
2020-08-11 18:50   ` Aleksandr Lyapunov
2020-08-10 10:10 ` [Tarantool-patches] [PATCH 0/2] JSON field multikey crash Aleksandr Lyapunov
2020-08-10 22:22   ` Vladislav Shpilevoy
2020-08-12 20:34 ` Vladislav Shpilevoy

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=21871bd97383aa16c15d8bdad20775f2a85548ae.1596584571.git.v.shpilevoy@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=alyapunov@tarantool.org \
    --cc=korablev@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH 2/2] tuple: fix access by JSON path starting from '\''[*]'\''' \
    /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