pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Fujii Masao <fujii@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: psql: Fix out-of-bounds reads in prompt expansion
Date: Fri, 20 Nov 2026 06:15:34 +0000
Message-ID: <E1xUHuH-00000000TiT-3piO@gemulon.postgresql.org> (raw)

psql: Fix out-of-bounds reads in prompt expansion

psql could crash when a custom prompt contained a %:name: or
%`command` escape without its closing delimiter.

This happened because prompt expansion assumed that the closing
delimiter was present and read past the end of the prompt string
when it was missing.

Fix this by checking for the closing delimiter before advancing
past it.

Backpatch to all supported versions.

Author: Chao Li <lic@highgo.com>
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>
Reviewed-by: Ishjaap Singh <ishjaap.singh07@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/0B33F84F-6AA3-4A39-A45D-D8F31D4E44D8@gmail.com
Backpatch-through: 15

Branch
------
REL_18_STABLE

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

Modified Files
--------------
src/bin/psql/prompt.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)



view thread (6+ messages)  latest in thread

Message-ID: <E1xUHuH-00000000TiT-3piO@gemulon.postgresql.org>
Permalink:  ../E1xUHuH-00000000TiT-3piO@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1xUHuH-00000000TiT-3piO@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: fujii@postgresql.org
  Subject: Re: pgsql: psql: Fix out-of-bounds reads in prompt expansion
  In-Reply-To: <E1xUHuH-00000000TiT-3piO@gemulon.postgresql.org>
  References: <E1xUHuH-00000000TiT-3piO@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