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: Avoid platform-specific null pointer dereference in psql.
Date: Sun, 25 Aug 2019 19:04:41 +0000
Message-ID: <E1i1xof-0001Dg-22@gemulon.postgresql.org> (raw)

Avoid platform-specific null pointer dereference in psql.

POSIX permits getopt() to advance optind beyond argc when the last
argv entry is an option that requires an argument and hasn't got one.
It seems that no major platforms actually do that, but musl does,
so that something like "psql -f" would crash with that libc.
Add a check that optind is in range before trying to look at the
possibly-bogus option.

Report and fix by Quentin Rameau.  Back-patch to all supported
branches.

Discussion: https://postgr.es/m/20190825100617.GA6087@fifth.space

Branch
------
REL9_6_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/28d2ce3c7c992c1aa2bbab984f14bf98056f3864

Modified Files
--------------
src/bin/psql/startup.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)



view thread (7+ messages)  latest in thread

Message-ID: <E1i1xof-0001Dg-22@gemulon.postgresql.org>
Permalink:  ../E1i1xof-0001Dg-22@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1i1xof-0001Dg-22@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: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Avoid platform-specific null pointer dereference in psql.
  In-Reply-To: <E1i1xof-0001Dg-22@gemulon.postgresql.org>
  References: <E1i1xof-0001Dg-22@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