View Issue Details

IDProjectCategoryView StatusLast Update
00003981003.1(2008)/Issue 7System Interfacespublic2024-06-11 08:53
Reportereblake Assigned Toajosey  
PrioritynormalSeverityObjectionTypeError
Status ClosedResolutionAccepted 
NameEric Blake
OrganizationRed Hat
User Referenceebb.ERANGE
Sectiongetgrgid_r
Page Number1014
Line Number34031
Interp StatusApproved
Final Accepted TextSee 0000398:0000796
Summary0000398: mandatory ERANGE failures on insufficient buffer size
DescriptionSeveral interfaces in the standard take a pointer and length of a buffer, to
fill in the result in a re-entrant manner. While some of these interfaces
document a mandatory ERANGE failure if the length is too small to hold the
resulting string (such as getpwd), others designate the failure as optional.
Considering that the standard even has several examples (such as getgidgr_r
and getgrnam_r) that assume mandatory ERANGE, it is better to require this
failure reliably; so that there is a consistent idiom of trying successively
larger buffers until the function succeeds or there is an error other than
ERANGE.
Desired ActionAt line 34031 [getgrgid ERRORS], change "getgrgid_r() function may fail" to
"getgrgid_r() function shall fail".

At line 34160 [getgrnam ERRORS], change "getgrnam_r() function may fail" to
"getgrnam_r() function shall fail".

At line 34478 [getlogin ERRORS], change "getlogin_r() function may fail" to
"getlogin_r() function shall fail".

At line 35330 [getpwnam ERRORS], change "getpwnam_r() function may fail" to
"getpwnam_r() function shall fail".

At line 35462 [getpwuid ERRORS], change "getpwuid_r() function may fail" to
"getpwuid_r() function shall fail".

At line 63270 [strerror ERRORS], change "strerror_r() function may fail" to
"strerror_r() function shall fail".

At line 63303 [strerror RATIONALE], add a sentence:
"Additionally, implementations are encouraged to NUL-terminate strerrbuf
when failing with ERANGE for any size other than buflen of zero."

At line 67667 [ttyname ERRORS], change "The ttyname() function may fail"
to "these functions may fail". At line 67670, change "ttyname_r()
function may fail" to "ttyname_r() function shall fail". Then delete
lines 67671-67672, resulting in EBADF and ENOTTY as common may fail
errors, and ERANGE as a shall fail error.
Tagsissue8

Relationships

related to 0000382 Closedajosey may strerror(0) fail with EINVAL? 
parent of 0000618 Resolvedajosey require isatty and friends to set errno on failure 

Activities

Don Cragun

2011-05-26 16:05

manager   bugnote:0000796

Interpretation response
------------------------
The standard is unclear on this issue, and no conformance distinction can be made between alternative implementations based on this. This is being referred to the sponsor.

Rationale:
-------------
Without requiring these conditions to fail, it is extremely difficult for applications to determine what to do.

Notes to the Editor (not part of this interpretation):
-------------------------------------------------------
Make the changes suggested in the Desired Action.

ajosey

2011-06-16 10:15

manager   bugnote:0000843

Interpretation proposed 16 June 2011 for final 30 day review

ajosey

2011-07-29 06:15

manager   bugnote:0000909

The interpretation is now approved.

Issue History

Date Modified Username Field Change
2011-03-17 21:58 eblake New Issue
2011-03-17 21:58 eblake Status New => Under Review
2011-03-17 21:58 eblake Assigned To => ajosey
2011-03-17 21:58 eblake Name => Eric Blake
2011-03-17 21:58 eblake Organization => Red Hat
2011-03-17 21:58 eblake User Reference => ebb.ERANGE
2011-03-17 21:58 eblake Section => getgrgid_r
2011-03-17 21:58 eblake Page Number => 1014
2011-03-17 21:58 eblake Line Number => 34031
2011-03-17 21:58 eblake Interp Status => ---
2011-03-17 21:59 eblake Relationship added related to 0000382
2011-03-17 22:02 eblake Desired Action Updated
2011-05-26 16:05 Don Cragun Interp Status --- => Pending
2011-05-26 16:05 Don Cragun Note Added: 0000796
2011-05-26 16:05 Don Cragun Status Under Review => Interpretation Required
2011-05-26 16:05 Don Cragun Resolution Open => Accepted
2011-05-26 16:05 Don Cragun Desired Action Updated
2011-05-26 16:06 Don Cragun Tag Attached: issue8
2011-05-26 16:10 Don Cragun Final Accepted Text => See 0000398:0000796
2011-06-16 10:15 ajosey Interp Status Pending => Proposed
2011-06-16 10:15 ajosey Note Added: 0000843
2011-07-29 06:15 ajosey Interp Status Proposed => Approved
2011-07-29 06:15 ajosey Note Added: 0000909
2012-10-03 03:30 eblake Relationship added parent of 0000618
2020-02-21 16:35 geoffclare Status Interpretation Required => Applied
2024-06-11 08:53 agadmin Status Applied => Closed