agora inbox for pgsql-committers@postgresql.org
help / color / mirror / Atom feedFrom: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Tighten tid input parsing with strtoul() to reject empty fields
Date: Thu, 06 Aug 2026 06:41:09 +0000
Message-ID: <E1wrrmv-00000000OoN-38uf@gemulon.postgresql.org> (raw)
Tighten tid input parsing with strtoul() to reject empty fields
strtoul() informs that in the case of no conversion, "endptr" is set
equal to the location of the input pointer, which is something that
tidin() has never checked.
This allowed inputs like "(,)", "(1,)" or "(,1)" to be accepted on some
platforms, like Linux where "(1,)" implied "(1,0)", but rejected on
others like macos where "(1,)" is rejected, due to the fact that errno
may not be set.
This change may cause some issues as some tid values will now be
rejected, but at least we get the consistent strtoul() experience.
If it proves to be a pain for some, it could always be reverted.
Another point of this change is that we get one step closer to a
possible common strtoul() where the error handling could be unified in
core, with all the errors handled the same way for errno and no input
parsed, at least.
Reported-by: Michael Malis <malis@pgrust.com>
Author: Tristan Partin <tristan@partin.io>
Discussion: https://postgr.es/m/19584-e60c446ba6f57c9c@postgresql.org
Discussion: https://postgr.es/m/DKBS2Z9CGARC.2T07O6TJYSE8B@partin.io
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/58ff4a0a08679356e502dfcbbc50e9bec94b77b1
Modified Files
--------------
src/backend/utils/adt/tid.c | 5 ++---
src/test/regress/expected/tid.out | 8 ++++++++
src/test/regress/sql/tid.sql | 2 ++
3 files changed, 12 insertions(+), 3 deletions(-)
Message-ID: <E1wrrmv-00000000OoN-38uf@gemulon.postgresql.org>
Permalink: ../E1wrrmv-00000000OoN-38uf@gemulon.postgresql.org/
Also on: postgresql.org/message-id/E1wrrmv-00000000OoN-38uf@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: Tighten tid input parsing with strtoul() to reject empty fields
In-Reply-To: <E1wrrmv-00000000OoN-38uf@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