pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Arthur Zakirov <a.zakirov@postgrespro.ru>
To: exclusion@gmail.com
To: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #15150: Reading uninitialised value in NISortAffixes (tsearch/spell.c)
Date: Thu, 12 Apr 2018 14:56:39 +0300
Message-ID: <20180412115638.GA19444@zakirov.localdomain> (raw)
In-Reply-To: <152353327780.31225.13445405496721177988@wrigleys.postgresql.org>
References: <152353327780.31225.13445405496721177988@wrigleys.postgresql.org>

Hello,

> Bug reference:      15150
> Logged by:          Alexander Lakhin
> Email address:      exclusion@gmail.com
> PostgreSQL version: 10.3
> Operating system:   Debian-8
> Description:        
> 
> It looks that the following condition in NISortAffixes(IspellDict *Conf)
> uses uninitialised ptr->issuffix:
> 
>   if (ptr == Conf->CompoundAffix ||
>      ptr->issuffix != (ptr - 1)->issuffix ||
 
Yes, you are right. The second condition isn't right. Instead of
"ptr->issuffix != (ptr - 1)->issuffix" "Affix->type" should be checked
because we check for uniqueness of affixes.

The patch is attached.

-- 
Arthur Zakirov
Postgres Professional: http://www.postgrespro.com
Russian Postgres Company

Attachments:

fix-NISortAffixes-condition.patch (text/plain, 909B) download diff --git a/src/backend/tsearch/spell.c b/src/backend/tsearch/spell.c index b9fdd77e19..65d99da292 100644 --- a/src/backend/tsearch/spell.c +++ b/src/backend/tsearch/spell.c @@ -1963,8 +1963,10 @@ NISortAffixes(IspellDict *Conf) if ((Affix->flagflags & FF_COMPOUNDFLAG) && Affix->replen > 0 && isAffixInUse(Conf, Affix->flag)) { + bool issuffix = (Affix->type == FF_SUFFIX); + if (ptr == Conf->CompoundAffix || - ptr->issuffix != (ptr - 1)->issuffix || + issuffix != (ptr - 1)->issuffix || strbncmp((const unsigned char *) (ptr - 1)->affix, (const unsigned char *) Affix->repl, (ptr - 1)->len)) @@ -1972,7 +1974,7 @@ NISortAffixes(IspellDict *Conf) /* leave only unique and minimals suffixes */ ptr->affix = Affix->repl; ptr->len = Affix->replen; - ptr->issuffix = (Affix->type == FF_SUFFIX); + ptr->issuffix = issuffix; ptr++; } }

view thread (6+ messages)  latest in thread

Message-ID: <20180412115638.GA19444@zakirov.localdomain>
Permalink:  ../20180412115638.GA19444@zakirov.localdomain/
Also on:    postgresql.org/message-id/20180412115638.GA19444@zakirov.localdomain

 ·  · 

reply

Reply instructions:

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

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: a.zakirov@postgrespro.ru, exclusion@gmail.com, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #15150: Reading uninitialised value in NISortAffixes (tsearch/spell.c)
  In-Reply-To: <20180412115638.GA19444@zakirov.localdomain>

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

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox