Re: Range checks of pg_test_fsync --secs-per-test and pg_test_timing --duration

From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>, Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Range checks of pg_test_fsync --secs-per-test and pg_test_timing --duration
Date: 2020-09-04 21:24:39
Message-ID: 4d4867ca-41fe-d95e-3b82-24818b508847@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2020-09-04 21:26:03 Re: PATCH: Batch/pipelining support for libpq
Previous Message Ranier Vilela 2020-09-04 21:20:01 Re: [PATCH] Redudant initilization