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 <[email protected]> Discussion: https://www.postgresql.org/message-id/[email protected] 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(-)
