Austin Group Defect Tracker

Aardvark Mark IV


Viewing Issue Simple Details Jump to Notes ] Issue History ] Print ]
ID Category Severity Type Date Submitted Last Update
0000075 [1003.1(2008)/Issue 7] System Interfaces Objection Error 2009-06-29 02:32 2013-04-16 13:06
Reporter geoffclare View Status public  
Assigned To ajosey
Priority normal Resolution Accepted  
Status Closed  
Name Geoff Clare
Organization
User Reference
Section basename
Page Number 614
Line Number 20984
Interp Status Approved
Final Accepted Text Note: 0000175
Summary 0000075: functions that are allowed to overwrite returned static data
Description _____________________________________________________________________________
 OBJECTION Enhancement Request Number 12
 gwc:xxxxxxxxxxxxx Bug in XSHd5.1 basename (rdvk# 2)
 [gwc static data] Tue, 28 Oct 2008 12:12:45 +0000
 _____________________________________________________________________________

The issue identified for setlocale() in aardvark XSH ERN 250 against
 the 2004 edition of the standard also affects several other functions.
 These are functions that are allowed to overwrite returned static data,
 but should also be allowed to use an internally reallocated buffer for
 the data.

 In some cases the statement that returned data may be overwritten is
 in APPLICATION USAGE. In these cases the proposed replacement is in
 normative text.
Desired Action [Page and line numbers are for draft 5.1.]

 basename: P614 L20984
 Change
     "The basename() function may modify the string pointed to by
     path, and may return a pointer to static storage that may then be
     overwritten by a subsequent call to basename()."
 to
     "The basename() function may modify the string pointed to by
     path, and may return a pointer to internal storage.
     The returned pointer might be invalidated or the storage
     might be overwritten by a subsequent call to basename()."

 ctermid: P713 L24020
 Change
     "If s is a null pointer, the string shall be generated in an area


     that may be static (and therefore may be overwritten by each call),
     the address of which shall be returned. Otherwise, ..."
 to
     "If s is a null pointer, the string shall be generated in a area
     that may be static, the address of which shall be returned. The
     application shall not modify the string returned. The returned
     pointer might be invalidated or the string content might be
     overwritten by a subsequent call to ctermid(). If s is not a
     null pointer, ..."

 dirname: P725 L24385
 Change
     "The dirname() function may modify the string pointed to by path,
     and may return a pointer to static storage that may then be
     overwritten by subsequent calls to dirname()."
 to
     "The dirname() function may modify the string pointed to by path,
     and may return a pointer to internal storage. The returned
     pointer might be invalidated or the storage might be overwritten
     by a subsequent call to dirname()."

 dlerror: P730 L24547
 Add a new paragraph to the RETURN VALUE section:
     "The application shall not modify the string returned. The
     returned pointer might be invalidated or the string content might
     be overwritten by a subsequent call to dlerror()."

 dlerror: P730 L24560
 Delete
     "The messages returned by dlerror() may reside in a static buffer
     that is overwritten on each call to dlerror(). Application code
     should not write to this buffer. Programs wishing to preserve an
     error message should make their own copies of that message."

 getgrent: P747 L25066 section endgrent
 Change
     "The return value may point to a static area which is overwritten
     by a subsequent call to getgrgid(), getgrnam(), or getgrent()."
 to
     "The application shall not modify the structure to which the
     return value points, nor any storage areas pointed to by pointers
     within the structure. The returned pointer, and pointers within
     the structure, might be invalidated or the structure or the storage
     areas might be overwritten by a subsequent call to getgrgid(),
     getgrnam(), or getgrent()."

 gethostent: P749 L25126 section endhostent
 Add a new paragraph to the RETURN VALUE section:
     "The application shall not modify the structure to which the
     return value points, nor any storage areas pointed to by pointers
     within the structure. The returned pointer, and pointers within
     the structure, might be invalidated or the structure or the storage
     areas might be overwritten by a subsequent call to gethostent()."

 gethostent: P749 L25132 section endhostent
 Change
     "The gethostent() function may return pointers to static data,
     which may be overwritten by subsequent calls to any of these


     functions."
 to
     "None"

 getnet*: P751 L25180 section endnetent
 Add a new paragraph to the RETURN VALUE section:
     "The application shall not modify the structure to which the
     return value points, nor any storage areas pointed to by pointers
     within the structure. The returned pointer, and pointers within
     the structure, might be invalidated or the structure or the storage
     areas might be overwritten by a subsequent call to getnetbyaddr(),
     getnetbyname(), or getnetent()."

 getnet*: P752 L25186 section endnetent
 Change
     "The getnetbyaddr(), getnetbyname(), and getnetent() functions may
     return pointers to static data, which may be overwritten by
     subsequent calls to any of these functions."
 to
     "None"

 getproto*: P753 L25235 section endprotoent
 Add a new paragraph to the RETURN VALUE section:
     "The application shall not modify the structure to which the
     return value points, nor any storage areas pointed to by pointers
     within the structure. The returned pointer, and pointers within
     the structure, might be invalidated or the structure or the storage
     areas might be overwritten by a subsequent call to getprotobyname(),
     getprotobynumber(), or getprotoent()."

 getproto*: P754 L25241 section endprotoent
 Change
     "The getprotobyname(), getprotobynumber(), and getprotoent()
     functions may return pointers to static data, which may be
     overwritten by subsequent calls to any of these functions."
 to
     "None"

 getpwent: P755 L25276 section endpwent
 Add a new paragraph to the RETURN VALUE section:
     "The application shall not modify the structure to which the
     return value points, nor any storage areas pointed to by pointers
     within the structure. The returned pointer, and pointers within
     the structure, might be invalidated or the structure or the storage
     areas might be overwritten by a subsequent call to getpwuid(),
     getpwnam(), or getpwent()."

 getpwent: P755 L25283 section endpwent
 Delete from the ERRORS section:
     "The return value may point to a static area which is overwritten
     by a subsequent call to getpwuid(), getpwnam(), or getpwent()."

 getserv*: P758 L25367 section endservent
 Add a new paragraph to the RETURN VALUE section:
     "The application shall not modify the structure to which the
     return value points, nor any storage areas pointed to by pointers
     within the structure. The returned pointer, and pointers within
     the structure, might be invalidated or the structure or the storage


     areas might be overwritten by a subsequent call to getservbyname(),
     getservbyport(), or getservent()."

 getserv*: P759 L25375 section endservent
 Delete
     "The getservbyname(), getservbyport(), and getservent() functions
     may return pointers to static data, which may be overwritten by
     subsequent calls to any of these functions."

 getenv: P1008 L33858
 Change
     "The string pointed to may be overwritten by a subsequent call to
     getenv(), [CX]setenv(), unsetenv(),[/CX] [XSI]or putenv()[/XSI]
     but shall not be overwritten by a call to any other function in
     this volume of POSIX.1-200x."
 to
     "[CX]The returned string pointer might be invalidated or[/CX] the
     string content might be overwritten by a subsequent call to
     getenv(), [CX]setenv(), unsetenv(),[/CX] [XSI]or putenv()[/XSI]
     but they shall not be affected by a call to any other function in
     this volume of POSIX.1-200x."

 getgrgid: P1014 L34026
 Change
     "The return value may point to a static area which is overwritten
     by a subsequent call to getgrent(), getgrgid(), or getgrnam()."
 to
     "The application shall not modify the structure to which the
     return value points, nor any storage areas pointed to by pointers
     within the structure. The returned pointer, and pointers within
     the structure, might be invalidated or the structure or the storage
     areas might be overwritten by a subsequent call to getgrent(),
     getgrgid(), or getgrnam()."

 getgrnam: P1018 L34154
 Change
     "The return value may point to a static area which is overwritten
     by a subsequent call to getgrent(), getgrgid(), or getgrnam()."
 to
     "The application shall not modify the structure to which the
     return value points, nor any storage areas pointed to by pointers
     within the structure. The returned pointer, and pointers within
     the structure, might be invalidated or the structure or the storage
     areas might be overwritten by a subsequent call to getgrent(),
     getgrgid(), or getgrnam()."

 getlogin: P1029 L34474
 Change
     "The return value from getlogin() may point to static data whose
     content is overwritten by each call."
 to
     "The application shall not modify the string returned.
     The returned pointer might be invalidated or the string content
     might be overwritten by a subsequent call to getlogin()."

 getpwnam: P1058 L35324
 Change
     "The return value may point to a static area which is overwritten


     by a subsequent call to getpwent(), getpwnam(), or getpwuid()."
 to
     "The application shall not modify the structure to which the
     return value points, nor any storage areas pointed to by pointers
     within the structure. The returned pointer, and pointers within
     the structure, might be invalidated or the structure or the storage
     areas might be overwritten by a subsequent call to getpwent(),
     getpwnam(), or getpwuid()."

 getpwuid: P1061 L35457
 Change
     "The return value may point to a static area which is overwritten
     by a subsequent call to getpwent(), getpwnam(), or getpwuid()."
 to
     "The application shall not modify the structure to which the
     return value points, nor any storage areas pointed to by pointers
     within the structure. The returned pointer, and pointers within
     the structure, might be invalidated or the structure or the storage
     areas might be overwritten by a subsequent call to getpwent(),
     getpwnam(), or getpwuid()."

 localeconv: P1235 L40722
 Change
     "The application shall not modify the structure pointed to
     by the return value which may be overwritten by a subsequent call
     to localeconv(). In addition, calls to setlocale() with the
     categories LC_ALL, LC_MONETARY, or LC_NUMERIC or calls to uselocale()
     which change the categories LC_MONETARY or LC_NUMERIC may overwrite
     the contents of the structure."
 to
     "The application shall not modify the structure to which the
     return value points, [CX]nor any storage areas pointed to by
     pointers within the structure. The returned pointer, and pointers
     within the structure, might be invalidated or[/CX] the structure
     [CX]or the storage areas[/CX] might be overwritten by a subsequent
     call to localeconv(). In addition, [CX]the returned pointer, and
     pointers within the structure, might be invalidated or[/CX] the
     structure [CX]or the storage areas[/CX] might be overwritten by
     subsequent calls to setlocale() with the categories LC_ALL,
     LC_MONETARY, or LC_NUMERIC, [CX]or by calls to uselocale() which
     change the categories LC_MONETARY or LC_NUMERIC[/CX]."

 nl_langinfo: P1375 L45104
 Delete
     "Calls to setlocale() with a category corresponding to the
     category of item (see <langinfo.h>), or to the category LC_ALL,
     may overwrite the array pointed to by the return value. Calls to
     uselocale() which change the category corresponding to the
     category of item may overwrite the array pointed to by the return
     value."

 nl_langinfo: P1375 L45113
 Change
     "This pointer may point to static data that may be overwritten on
     the next call to either function."
 to
     "The application shall not modify the string returned.
     The returned pointer might be invalidated or the string content


     might be overwritten by a subsequent call to either function, by
     subsequent calls to setlocale() with a category corresponding to
     the category of item (see <langinfo.h>) or the category LC_ALL, or
     by subsequent calls to uselocale() which change the category
     corresponding to the category of item."

 ptsname: P1712 L54754
 Add a new paragraph to the RETURN VALUE section:
     "The application shall not modify the string returned.
     The returned pointer might be invalidated or the string content
     might be overwritten by a subsequent call to ptsname()."

 ptsname: P1712 L54760
 Change
     "The value returned may point to a static data area that is
     overwritten by each call to ptsname()."
 to
     "None"

 readdir: P1744 L55685
 Change
     "The pointer returned by readdir() points to data which may be
     overwritten by another call to readdir() on the same directory
     stream. This data is not overwritten by another call to readdir()
     on a different directory stream."
 to
     "The application shall not modify the structure to which the
     return value of readdir() points, nor any storage areas pointed to
     by pointers within the structure. The returned pointer, and
     pointers within the structure, might be invalidated or the
     structure or the storage areas might be overwritten by a
     subsequent call to readdir() on the same directory stream.
     They shall not be affected by a call to readdir() on a different
     directory stream."

 strerror: P1999 L63238
 Change
     "The string pointed to shall not be modified by the application.
     The string may be overwritten by a subsequent call to strerror().
     [CX]The string may be overwritten by a subsequent call to
     strerror_l() in the same thread.[/CX]"
 to
     "The application shall not modify the string returned.
     [CX]The returned string pointer might be invalidated or[/CX] the
     string content might be overwritten by a subsequent call to
     strerror(), [CX]or by a subsequent call to strerror_l() in the
     same thread[/CX]."

 strsignal: P2032 L64345
 Change
     "The string pointed to shall not be modified by the application,
     but may be overwritten by a subsequent call to strsignal() or
     setlocale()."
 to
     "The application shall not modify the string returned.
     The returned pointer might be invalidated or the string content
     might be overwritten by a subsequent call to strsignal() or
     setlocale()."


 ttyname: P2140 L67655
 Change
     "The return value may point to static data whose content is
     overwritten by each call."
 to
     "The application shall not modify the string returned.
     The returned pointer might be invalidated or the string content
     might be overwritten by a subsequent call to ttyname()."
Tags tc1-2008
Attached Files

- Relationships
related to 0000288Closedajosey 1003.1(2004)/Issue 6 setlocale and static return buffer 
related to 0000097Closedajosey 1003.1(2008)/Issue 7 per-thread dlerror strings 
related to 0000402Closedajosey 1003.1(2008)/Issue 7 nl_langinfo() and nl_langinfo_l() internal data 
related to 0000508Appliedajosey 1003.1(2008)/Issue 7 Add ptsname_r 
related to 0000656Closedajosey 1003.1(2013)/Issue7+TC1 Clearly allow or forbid thread-local storage for "static" buffers 

-  Notes
(0000175)
ajosey (manager)
2009-08-06 15:33
edited on: 2009-10-09 16:40

Interpretation response
------------------------
The standard states the requirements for functions overwriting static data,
and conforming implementations must conform to this. However, concerns
have been raised about this which are being referred to the sponsor.

Rationale:
-------------
None.

Notes to the Editor (not part of this interpretation):
-------------------------------------------------------

Make the change suggested by the submitter

(0000728)
ajosey (manager)
2011-03-30 09:50

When applying the change for dlerror() in the draft TC1-2008, bug 97 was also taken into account when updating the RETURN VALUE section.

"The application shall not modify the string returned. The
returned pointer might be invalidated or the string content might
be overwritten by a subsequent call to dlerror() in the same
thread (if dlerror() is thread-safe) or in any thread (if dlerror()
is not thread-safe)."

- Issue History
Date Modified Username Field Change
2009-06-29 02:32 msbrown New Issue
2009-06-29 02:32 msbrown Status New => Under Review
2009-06-29 02:32 msbrown Assigned To => ajosey
2009-06-29 02:32 msbrown Name => Mark Brown
2009-06-29 02:32 msbrown Organization => IBM
2009-06-29 02:32 msbrown Section => basename
2009-06-29 02:32 msbrown Page Number => 614
2009-06-29 02:32 msbrown Line Number => 20984
2009-06-29 02:33 msbrown Status Under Review => Resolved
2009-06-29 02:33 msbrown Resolution Open => Accepted
2009-07-01 14:03 msbrown Name Mark Brown => Geoff Clare
2009-07-01 14:03 msbrown Organization IBM =>
2009-07-01 14:03 msbrown Reporter msbrown => geoffclare
2009-08-06 15:33 ajosey Note Added: 0000175
2009-08-06 15:33 ajosey Status Resolved => Interpretation Required
2009-08-11 16:31 Don Cragun Interp Status => Pending
2009-09-17 15:41 nick Interp Status Pending => Proposed
2009-10-09 16:40 ajosey Note Edited: 0000175
2009-10-09 16:41 ajosey Interp Status Proposed => Approved
2009-10-09 16:41 ajosey Final Accepted Text => Note: 0000175
2010-09-07 10:53 geoffclare Relationship added related to 0000288
2010-09-20 09:16 geoffclare Tag Attached: tc1-2008
2011-03-24 15:07 eblake Relationship added related to 0000097
2011-03-30 09:50 ajosey Note Added: 0000728
2011-04-04 14:27 geoffclare Relationship added related to 0000402
2011-11-10 21:28 eblake Relationship added related to 0000508
2013-02-21 17:00 eblake Relationship added related to 0000656
2013-04-16 13:06 ajosey Status Interpretation Required => Closed


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker