agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix error handling in port's getopt_long() for missing argument
Date: Fri, 31 Jul 2026 03:45:17 +0000
Message-ID: <E1wpeBR-000000012WB-0HIP@gemulon.postgresql.org> (raw)

Fix error handling in port's getopt_long() for missing argument

In the long option error path, the code previously returned BADARG
immediately when optstring[0] == ':' for a missing required argument,
without advancing "optind" or resetting "place".  This error handling
was inconsistent with the short option path, where both updates are
performed before returning BADARG (and inconsistent with libc,
additionally..).

This affects platforms where our port version of getopt_long() is used,
a concept that should be limited to WIN32 these days.  An argument could
be made in favor of a backpatch, but this could lead to a slight
different error handling, for a report that would only show up when
using incorrect option combinations.

Author: Japin Li <japinli@hotmail.com>
Discussion: https://postgr.es/m/SY7PR01MB10921AF81F18A8BCFA06388BEB6C22@SY7PR01MB10921.ausprd01.prod.outlook.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/745becce3321267a4530af286433d1dc6f043360

Modified Files
--------------
src/port/getopt_long.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)



Message-ID: <E1wpeBR-000000012WB-0HIP@gemulon.postgresql.org>
Permalink:  ../E1wpeBR-000000012WB-0HIP@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1wpeBR-000000012WB-0HIP@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 using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: michael@paquier.xyz, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Fix error handling in port's getopt_long() for missing argument
  In-Reply-To: <E1wpeBR-000000012WB-0HIP@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 agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox