Defect report from : Andrew Josey , The Open Group
(Please direct followup comments direct to yyyyyyyyyyyyyy@xxxxxxxxxxxxx)
@ page 1441 line 44899 section strerror objection {bwg.pr2477}
Problem:
Edition of Specification (Year): 2004
Defect code : 1. Error
The standard does not clearly require that
the generated error message string produced by strerror(),
strerror_r(), perror() not be an empty string (even for valid errno
values). We believe this is a weirdnix case (the standard allows the
behavior, but the standard's authors never imagined that any conforming
implementation would behave this way). Doing this for invalid error
numbers isn't as bad as doing it for valid error numbers, but the
standard seems to allow this behavior even for valid error numbers.
Action:
Enclosed is a proposal to plug this hole in the next
revision of the standard (all page and line
numbers refer to the 2004 edition of XSH6)
1. Add a new paragraph (CX shaded) replacing the currently
empty line on P1441, L44899 (last line of the DESCRIPTION section) with:
"If the value of errnum is a valid error number, the message
string shall indicate what error occurred; otherwise, if these
functions complete successfully, the message string shall
indicate that an unknown error occurred."
2. Change the rationale on P1442, L44916 from:
"None."
to the following paragraphs:
"Earlier versions of this standard didn't explicitly require
that the error message strings returned by strerror() and
strerror_r() provide any information about the error. This
version of the standard requires a meaningful message for any
successful completion.
Since no return value is reserved to indicate a strerror()
error, implementations can return a null pointer, a pointer to
an empty string, or a pointer to a meaningful string that can
be printed.
Note that the EINVAL error condition is a may fail error. If
an invalid error number is supplied as the value of errnum,
applications should be prepared to handle any of the
following:
1. Error (with no error message): errno is set to EINVAL, the
return value is a null pointer.
2. Successful completion: errno is unchanged and the return
value points to a string like "unknown error" or "error
number xxx" (where xxx is the value of errnum).
3. Combination of 1 & 2: errno is set to EINVAL and the return
value points to a string like "unknown error" or "error
number xxx" (where xxx is the value of errnum).
Since applications frequently use the return value of
strerror() as an argument to functions like fprintf() (without
checking the return value) and since applications have no way
to parse an error message string to determine if errnum
represents a valid error number, implementations are encouraged
to implement #3. Similarly, implementations are encouraged to
have strerror_r() return EINVAL and put a string like "unknown
error" or "error number xxx" in the buffer pointed to by
strerrbuf when the value of errnum is not a valid error
number."
|