Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: Kirill Shcherbatov <kshcherbatov@tarantool.org>,
	tarantool-patches@freelists.org
Subject: [tarantool-patches] Re: [PATCH v1 1/1] sql: fix tarantoolSqlite3TupleColumnFast
Date: Wed, 5 Dec 2018 23:23:20 +0300	[thread overview]
Message-ID: <fe963156-9765-b353-e0ca-66e5669547f9@tarantool.org> (raw)
In-Reply-To: <a2427513583b3c0e63f9e976babdf84fe6a9a6dd.1543945044.git.kshcherbatov@tarantool.org>

Hi! Thanks for the patch! See 1 comment below.

On 04/12/2018 20:39, Kirill Shcherbatov wrote:
> http://github.com/tarantool/tarantool/tree/kshch/gh-3772-dirty-memory-access
> https://github.com/tarantool/tarantool/issues/3772
> 
> The tarantoolSqlite3TupleColumnFast routine used to lookup
> offset_slot in unallocated memory in some cases.

In which 'some'? Yes, assert is wrong, but I do not understand
how is it possible that fieldno >= field_count if such errors
are caught during parsing stage.

> The assert with exact_field_count from 7a8de28 is not correct.
> assert(format->exact_field_count == 0 ||
>         fieldno < format->exact_field_count);
> The tarantoolSqlite3TupleColumnFast routine requires offset_slot
> that has been allocated during tuple_format_create call. This
> value is stored in indexed field with index that limited with
> index_field_count that is <= field_count.
> Look at tuple_format_alloc for more details.
> 
> Closes #3772
> ---
>   src/box/sql.c | 5 ++---
>   1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/src/box/sql.c b/src/box/sql.c
> index 171fd966a..25b3213fd 100644
> --- a/src/box/sql.c
> +++ b/src/box/sql.c
> @@ -199,9 +199,8 @@ tarantoolSqlite3TupleColumnFast(BtCursor *pCur, u32 fieldno, u32 *field_size)
>   	assert(pCur->last_tuple != NULL);
>   
>   	struct tuple_format *format = tuple_format(pCur->last_tuple);
> -	assert(format->exact_field_count == 0
> -	       || fieldno < format->exact_field_count);
> -	if (format->fields[fieldno].offset_slot == TUPLE_OFFSET_SLOT_NIL)
> +	if (fieldno >= format->field_count ||
> +	    format->fields[fieldno].offset_slot == TUPLE_OFFSET_SLOT_NIL)
>   		return NULL;
>   	const char *field = tuple_field(pCur->last_tuple, fieldno);
>   	const char *end = field;
> 

       reply	other threads:[~2018-12-05 20:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <a2427513583b3c0e63f9e976babdf84fe6a9a6dd.1543945044.git.kshcherbatov@tarantool.org>
2018-12-05 20:23 ` Vladislav Shpilevoy [this message]
2018-12-05 20:41   ` Kirill Shcherbatov
2018-12-05 21:23     ` Vladislav Shpilevoy
2018-12-06  6:59       ` Kirill Shcherbatov
2018-12-06  9:17         ` Vladislav Shpilevoy
2018-12-06 10:13           ` n.pettik
2018-12-06 15:05   ` 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=fe963156-9765-b353-e0ca-66e5669547f9@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=kshcherbatov@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[tarantool-patches] Re: [PATCH v1 1/1] sql: fix tarantoolSqlite3TupleColumnFast' \
    /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