Okay. After I identified the code which was causing the problem, my
initial fix was to clear errno before each call to strtol(), and that
resolved the problem. I then went in and looked at the code in more
detail, as well as read the spec for strtol().

My change will work also, since strtol() returns the original string
pointer through endptr only when it cannot do any conversion.  I am
not concerned as long as the code functions properly.

David

On Tue, Jun 22, 2021 at 11:13 AM Viktor Dukhovni
<postfix-us...@dukhovni.org> wrote:
>
> On Tue, Jun 22, 2021 at 10:49:49AM -0700, David Bohman wrote:
>
> > You cannot assume that the value returned to 'endptr' is greater than
> > 'str' on a valid result. It could be a different string entirely, with
> > a lesser pointer value. That is up to the implementation.
>
> Postfix does not pass arguments to strtol() that violate pointer
> aliasing.  We can and do correctly assume that strtol() behaves
> correctly, and returns a value of 'endptr' that is >= the source
> string.
>
> --
>     Viktor.

Reply via email to