On 2020-08-06 08:27, Michael Paquier wrote:
> As $subject says, pg_test_fsync and pg_test_timing don't really check
> the range of option values specified. It is possible for example to
> make pg_test_fsync run an infinite amount of time, and pg_test_timing
> does not handle overflows with --duration at all.
>
> These are far from being critical issues, but let's fix them at least
> on HEAD. So, please see the attached, where I have also added some
> basic TAP tests for both tools.
According to the POSIX standard, atoi() is not required to do any error
checking, and if you want error checking, you should use strtol().
And if you do that, you might as well change the variables to unsigned
and use strtoul(), and then drop the checks for <=0. I would allow 0.
It's not very useful, but it's not harmful and could be applicable in
testing.
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services