pgsql: Ensure Soundex difference() function handles empty input sanely.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Ensure Soundex difference() function handles empty input sanely.
Date: 2023-05-16 14:54:01
Message-ID: E1pyw3t-0007oS-GK@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/eaf99e4c4ae4084b8261e5e1f9c2c93004a98638

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(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Damir Belyalov 2023-05-16 19:04:08 Re: pgsql: Refactor background psql TAP functions
Previous Message Andrew Dunstan 2023-05-16 12:55:20 Re: issue with meson builds on msys2