Re: Incorrect usage of strtol, atoi for non-numeric junk inputs

Michael Paquier <michael@paquier.xyz>

From: Michael Paquier <michael@paquier.xyz>
To: David Rowley <dgrowleyml@gmail.com>
Cc: Kyotaro Horiguchi <horikyota.ntt@gmail.com>, Alvaro Herrera <alvherre@alvh.no-ip.org>, Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>, PostgreSQL Developers <pgsql-hackers@lists.postgresql.org>
Date: 2021-07-26T06:01:35Z
Lists: pgsql-hackers

Attachments

On Sat, Jul 24, 2021 at 07:41:12PM +0900, Michael Paquier wrote:
> I have looked at that over the last couple of days, and applied it
> after some small fixes, including an indentation.

One thing that we forgot here is the handling of trailing
whitespaces.  Attached is small patch to adjust that, with one
positive and one negative tests.

> The int64 and float
> parts are extra types we could handle, but I have not looked yet at
> how much benefits we'd get in those cases.

I have looked at these two but there is really less benefits, so for
now I am not planning to do more in this area.  For float options,
pg_basebackup --max-rate could be one target on top of the three set
of options in pgbench, but it needs to handle units :(
--
Michael

Commits

  1. Simplify matching pattern check in TAP tests of pg_receivewal

  2. Skip trailing whitespaces when parsing integer options

  3. Unify parsing logic for command-line integer options