public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/94169] New: warn for modifying getenv() result
@ 2020-03-13 16:12 msebor at gcc dot gnu.org
  2020-03-16 19:10 ` [Bug middle-end/94169] " msebor at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: msebor at gcc dot gnu.org @ 2020-03-13 16:12 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94169

            Bug ID: 94169
           Summary: warn for modifying getenv() result
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

Bug 94157 was caused by modifying the string pointed to by the value returned
from getenv(), which is undefined according to both C and POSIX.  C11 says in
7.22.4.8, p4:

  The getenv function returns a pointer to a string associated with the matched
list member. The string pointed to shall not be modified by the program, but
may be overwritten by a subsequent call to the getenv function.

It would be helpful if GCC issued a warning for attempts to modify the returned
string.  This could be done by extending -Wstringop-overflow.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-10-19 22:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-13 16:12 [Bug middle-end/94169] New: warn for modifying getenv() result msebor at gcc dot gnu.org
2020-03-16 19:10 ` [Bug middle-end/94169] " msebor at gcc dot gnu.org
2020-03-16 19:34 ` msebor at gcc dot gnu.org
2020-10-19 20:47 ` dmalcolm at gcc dot gnu.org
2020-10-19 22:33 ` msebor at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).