pgsql: Avoid platform-specific null pointer dereference in psql.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Avoid platform-specific null pointer dereference in psql.
Date: 2019-08-25 19:04:41
Message-ID: E1i1xof-0001Dg-22@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Geoghegan 2019-08-26 00:06:06 Re: pgsql: Fix optimization of foreign-key on update actions
Previous Message Tom Lane 2019-08-25 16:15:12 pgsql: Back off output precision in circle.sql regression test.