Re: Fixes bug in strlower_libc_sb()

From: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
To: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Jeff Davis <pgsql(at)j-davis(dot)com>
Subject: Re: Fixes bug in strlower_libc_sb()
Date: 2025-11-26 16:15:01
Message-ID: aScnhfrMQ5r444GU@ip-10-97-1-34.eu-west-3.compute.internal
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Tue, Nov 25, 2025 at 01:50:42PM +0800, Chao Li wrote:
> On Tue, Nov 25, 2025 at 11:03 AM Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> wrote:
>
> > Hi Hackers,
> >
> > While reviewing Jeff's patch [1], I found this bug in strlower_libc_sb():
> >
> > ```
> > static size_t
> > strlower_libc_sb(char *dest, size_t destsize, const char *src, ssize_t
> > srclen,
> > pg_locale_t locale)
> > {
> > if (srclen < 0)
> > srclen = strlen(src);

Nice catch!

FWIW this thread gave me the idea to create a coccinelle script to detect dead
branches [1]. It reports 4 more that are false positives, so I don't think there
is more dead branches in the code tree.

[1]: https://github.com/bdrouvot/coccinelle_on_pg/blob/main/misc/dead_branches.cocci

Regards,

--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2025-11-26 16:19:12 Re: Adding basic NUMA awareness
Previous Message Tom Lane 2025-11-26 16:10:31 Re: [buildfarm related] Machines gcc experimental failed test_lfind