pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Ensure Soundex difference() function handles empty input sanely.
Date: Tue, 16 May 2023 14:54:01 +0000
Message-ID: <E1pyw3t-0007oX-HL@gemulon.postgresql.org> (raw)

Ensure Soundex difference() function handles empty input sanely.

fuzzystrmatch's difference() function assumes that _soundex()
always initializes its output buffer fully.  This was not so for
the case of a string containing no alphabetic characters, resulting
in unstable output and Valgrind complaints.

Fix by using memset() to fill the whole buffer in the early-exit
case.  Also make some cosmetic improvements (I didn't care for the
random switches between "instr[0]" and "*instr" notation).

Report and diagnosis by Alexander Lakhin (bug #17935).
Back-patch to all supported branches.

Discussion: https://postgr.es/m/17935-b99316aa79c18513@postgresql.org

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/0409c7fc746b2597edeaab3132d3f3554660283d

Modified Files
--------------
contrib/fuzzystrmatch/expected/fuzzystrmatch.out |  6 ++++++
contrib/fuzzystrmatch/fuzzystrmatch.c            | 15 ++++++++-------
contrib/fuzzystrmatch/sql/fuzzystrmatch.sql      |  1 +
3 files changed, 15 insertions(+), 7 deletions(-)



view thread (6+ messages)  latest in thread

Message-ID: <E1pyw3t-0007oX-HL@gemulon.postgresql.org>
Permalink:  ../E1pyw3t-0007oX-HL@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1pyw3t-0007oX-HL@gemulon.postgresql.org

 · 

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-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Ensure Soundex difference() function handles empty input sanely.
  In-Reply-To: <E1pyw3t-0007oX-HL@gemulon.postgresql.org>

* 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