pgsql: pg_resetwal: Reject negative and out of range arguments - Mailing list pgsql-committers

From Heikki Linnakangas
Subject pgsql: pg_resetwal: Reject negative and out of range arguments
Date
Msg-id E1vSceu-003Rvk-1d@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
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(-)


pgsql-committers by date:

Previous
From: Peter Eisentraut
Date:
Subject: pgsql: Make ecpg parse.pl more robust with braces
Next
From: Álvaro Herrera
Date:
Subject: pgsql: Unify error messages