David Bohman:
> This is apparently a new routine in version 3.6.
> 
> I upgraded from version 3.5.9 directly to 3.6.1 and ran into an issue.
> Postfix failed to start up without any diagnostic output. It took me a bit
> to narrow down the failure, but I discovered that this routine was failing
> on valid input.

What was the valid input? 

> Use of the library routine strtol() is problematic due to the lack of a
> direct failure indication. You cannot check errno for a value unless you
> zero it before the invocation.

Good point. I notice that most Postfix code will reset errno to
zero before calling strtol() and the like, but it is missing in the
compatibility level parser (and some other place). I'll add that.

> But, I am thinking that we don't really need to check for an overflow or
> underflow error from strtol(), since GOOD_MAJOR() and friends already do
> range checking. My solution is to simply remove the errno checks.

Range checks make no sense if strtol() failed. So deleting that
test is wrong.

> One other modification I made concerns the comparisons "start < remainder",
> which I changed to "start != remainder". There is no guarantee concerning
> the location of the buffer returned via "endptr". Its relation to the
> original string is undefined, unless no conversion was done, in which case
> it returns the original string.

strtol returns the position of the first 'invalid' character, 
or the start of the input when no conversion was done.

        Wietse

Reply via email to