[tarantool-patches] Re: [PATCH 1/2] sql: LIKE & GLOB pattern comparison issue

Alexander Turenko alexander.turenko at tarantool.org
Fri Aug 17 14:17:27 MSK 2018


Hi!

I have one note here.

Please, cite only relavant parts of a message you reply, because some
clients (say, mutt) don't wrap long cites automatically.

WBR, Alexander Turenko.

On Fri, Aug 17, 2018 at 12:23:16PM +0300, Alex Khatskevich wrote:
> The code seems relatively normal, except for one thing below.
> 
> 
> On 16.08.2018 20:00, N.Tatunov wrote:
> > From: "N.Tatunov" <hollow653 at gmail.com>
> > 
> > +#define SQL_END_OF_STRING        0xffff
> I have a look at icu code and It seems like 0xffff is an error, and it is
> more similar to
> invalid symbol that to "end of string". Check it, and fix the code, so that
> it is treated as
> an error.

0xffff is the result of 'end of a string' check as well as internal buffer
overflow error. I have the relevant code pasted in the first review of
the patch (July, 18).

// source/common/ucnv.c::ucnv_getNextUChar
1860     s=*source;
1861     if(sourceLimit<s) {
1862         *err=U_ILLEGAL_ARGUMENT_ERROR;
1863         return 0xffff;
1864     }

We should not handle the buffer overflow case as an invalid symbol. Of
course we should not handle it as the 'end of the string' situation.
Ideally we should perform pointer myself and raise an error in case of
0xffff. I had thought that a buffer overflow error is unlikely to meet,
but you are right: we should differentiate these situations.

In one of the previous version of a patch we perform this check like so:

#define Utf8Read(s, e) (((s) < (e)) ?\
	ucnv_getNextUChar(pUtf8conv, &s, e, &status) : 0)

Don't sure why it was changed. Maybe it is try to correctly handle '\0'
symbol (it is valid unicode character)?

So I see two ways to proceed:

1. Lean on icu's check and ignore possibility of the buffer overflow.
2. Use our own check and possibly meet '\0' problems.
3. Check for U_ILLEGAL_ARGUMENT_ERROR to treat as end of a string, raise
   the error for other 0xffff.

Alex, what do you suggests here?




More information about the Tarantool-patches mailing list