On Fri, 2008-06-20 at 16:49 +0100, Stephane Chazelas wrote:
> Hiya,
>
> I can see GNU libc and uclibc scanf set errno to ERANGE upon a
> %u, %i (and possibly %e, %f... as well) conversion that ends up
> %overflowing the number size.
>
> Solaris 10 man page suggests it's also the case there for %a,
> %e, %f, %g (though not in the ERROR section).
>
> Shouldn't it be something that should be mentionned in the
> standard, i.e. that errno _may_ be set to ERANGE, but that a
> conformant application can't rely on it to check for overflow?
The standard does not mention ERANGE as one of the defined errors for
scanf, just EILSEQ, ENOMEM and EINVAL. Thus an ERANGE error falls into
the category of "Implementations may generate error numbers listed here
under circumstances other than those described, if and only if all those
error conditions can always be treated identically to the error
conditions as described in this volume of POSIX.1".
This wording appears in section 2.3 of XSH, and has been there more or
less forever. If you file an official bug through the aardvark system,
it is possible that we might add an APPLICATION USAGE warning about
overflow conditions, but I personally do not believe the normative
requirements need any change.
>
> Best regards,
> Stéphane
--
Nick Stoughton Cell: 510 388 1413
USENIX Standards Liaison Fax: 510 548 5738
|