pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David Rowley <drowley@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Use Size rather than int for storing strnlen's return
Date: Wed, 21 Oct 2026 00:33:00 +0000
Message-ID: <E1xJKGK-000000004ux-1vyo@gemulon.postgresql.org> (raw)

Use Size rather than int for storing strnlen's return

... in fe_memutils.c's pnstrdup().

strnlen() does return size_t, so it seems better to use the Size input
parameter to store the return value rather than demote it to int and
risk larger values being truncated.

Pushing only to master as this doesn't seem like an actual problem.
Fixing will hopefully prevent future LLM-triggered reports about this.

Author: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/0E717E09-809F-4BC4-B3B1-36BE729DBFAE@gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/38c3d87d43397ab600f085e398789f3dea1cd0a5

Modified Files
--------------
src/common/fe_memutils.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)



Message-ID: <E1xJKGK-000000004ux-1vyo@gemulon.postgresql.org>
Permalink:  ../E1xJKGK-000000004ux-1vyo@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1xJKGK-000000004ux-1vyo@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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: drowley@postgresql.org
  Subject: Re: pgsql: Use Size rather than int for storing strnlen's return
  In-Reply-To: <E1xJKGK-000000004ux-1vyo@gemulon.postgresql.org>
  References: <E1xJKGK-000000004ux-1vyo@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