From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5031 invoked by alias); 28 May 2015 23:38:38 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 4982 invoked by uid 48); 28 May 2015 23:38:34 -0000 From: "miyuki at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug preprocessor/66318] Error messages contain raw file name; malicious #line directives can do bad things Date: Thu, 28 May 2015 23:38:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: preprocessor X-Bugzilla-Version: 5.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: miyuki 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: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-05/txt/msg02387.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66318 Mikhail Maltsev changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |miyuki at gcc dot gnu.org --- Comment #4 from Mikhail Maltsev --- I think those tools will not like a newline character in the filename either. And I doubt that there is a reliable way to parse output of GCC if newlines are not escaped: $ cat ./test.cc void foo(); #line 1 "test1.cc:3:1 error: something wrong!\ntest2.cc" void bar() { foo("abc"); } $ /opt/gcc-6.0.0/bin/g++ -c ./test.cc test1.cc:3:1 error: something wrong! test2.cc: In function 'void bar()': test1.cc:3:1 error: something wrong! test2.cc:3:14: error: too many arguments to function 'void foo()' ./test.cc:1:6: note: declared here void foo(); Anyway, GCC already suppresses color diagnostics when stderr is not a TTY (implemented in should_colorize function). Probably the same logic could be applied to hypothetical "should_escape".