[PATCH] [tldap] check for successful string conversion

Volker Lendecke Volker.Lendecke at SerNet.DE
Thu Jan 10 12:52:06 UTC 2019


On Thu, Jan 10, 2019 at 01:04:13PM +0100, swen wrote:
> I read it that "both" will be done in case of an error but regardless
> of how often I read the documentation I do not see the possibility
> where errno is set but there is no error.

The spec lists two conditions about errors:

1.: ret==0 and errno==EINVAL
2.: ret==ULLONG_MAX and errno==ERANGE

Those are precise error conditions with deliberately worded "and"s.
Any other assumption about errors is not covered by the spec. Your
patch just checks errno, but this is not covered by what the spec
says.  "errno!=0" is not one of the conditions listed in the spec, and
thus I NACK your patch as it stands.

You might reasonably argue that strtoull is a broken API, because the
first case is optional, and thus EINVAL can not be relied upon. You
are completely right there. But then you should come up with a better
one, and I would propose to look at OpenBSD's strtonum or possibly
sscanf with SCNu64, which might have better defined error handling.

Volker

-- 
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: 0551-370000-0, mailto:kontakt at sernet.de
Gesch.F.: Dr. Johannes Loxen und Reinhild Jung
AG Göttingen: HR-B 2816 - http://www.sernet.de



More information about the samba-technical mailing list