From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3F04A389F4E9; Fri, 13 Mar 2020 16:12:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3F04A389F4E9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1584115923; bh=24hNGwPhn0X7q6htjxY41rOPmMPGtkvoyW8m0nD8YkU=; h=From:To:Subject:Date:From; b=eOjzf5a6Mt55uZOG7upP7x+qMA95Y2l10/s4bwW4t2NUCJtNK5Ig21BQJKuvdG0kl KRJiXlMMiCuFcmUbfZ/Gs+ihtzDWdFEnlBcWcJPSjQIuaSUcOfgmhFGtm4Rj/lBBD1 ojzq0t8Xc1XrmBELsb48T1VmVNexvTnWmxhUKSb8= From: "msebor at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/94169] New: warn for modifying getenv() result Date: Fri, 13 Mar 2020 16:12:03 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 10.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: msebor at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Mar 2020 16:12:03 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94169 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 return= ed 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 mat= ched 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 retu= rned string. This could be done by extending -Wstringop-overflow.=