From: Heikki Linnakangas <heikki.linnakangas@iki.fi>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: pg_resetwal: Reject negative and out of range arguments
Date: Mon, 08 Dec 2025 14:56:17 +0000
Message-ID: <E1vSceu-003Rvk-1d@gemulon.postgresql.org> (raw)
pg_resetwal: Reject negative and out of range arguments
The strtoul() function that we used to parse many of the options
accepts negative values, and silently wraps them to the equivalent
unsigned values. For example, -1 becomes 0xFFFFFFFF, on platforms
where unsigned long is 32 bits wide. Also, on platforms where
"unsigned long" is 64 bits wide, we silently casted values larger than
UINT32_MAX to the equivalent 32-bit value. Both of those behaviors
seem undesirable, so tighten up the parsing to reject them.
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://www.postgresql.org/message-id/81adf5f3-36ad-4bcd-9ba5-1b95c7b7a807@iki.fi
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/636c1914b483bab0eaabdec30cf1f2c743606d7f
Modified Files
--------------
src/bin/pg_resetwal/pg_resetwal.c | 64 ++++++++++++++++++++++++++++++--------
src/bin/pg_resetwal/t/001_basic.pl | 32 ++++++++++++++++---
2 files changed, 78 insertions(+), 18 deletions(-)
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: heikki.linnakangas@iki.fi, pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: pg_resetwal: Reject negative and out of range arguments
In-Reply-To: <E1vSceu-003Rvk-1d@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